Ask Your Question
0

How can a make a report or query from duplicate entries in table

asked 2017-10-29 16:53:23 +0200

GarethT gravatar image

Hi, I'm working on a lameness and medication record for sheep using libreoffice base.

I'd like to be able to create a query that only shows records for an animal that has had its tag number entered in to the database multiple times. I'm not that sure how to go about it however. Any help would be most appreciated.

Regards

Gareth

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2017-10-29 17:50:09 +0200

JohnSUN gravatar image

To find tags wich has a doubles use query like this

SELECT <tag> FROM <table_of_sheep> GROUP BY <tag> HAVING (  COUNT( <tag> ) > 1  )

To show all records with such tags use

SELECT * FROM <table_of_sheep> 
   WHERE <tag> IN ( SELECT <tag> FROM <table_of_sheep> 
                                GROUP BY <tag> 
                                HAVING (  COUNT( <tag> ) > 1  )) 
 ORDER BY <tag> ASC
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-10-29 16:53:23 +0200

Seen: 60 times

Last updated: Oct 29 '17