Ask Your Question

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

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

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.



edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-10-19 03:04:05.081684

1 Answer

Sort by » oldest newest most voted

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

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  )) 
edit flag offensive delete link more

Question Tools

1 follower


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

Seen: 121 times

Last updated: Oct 29 '17