Question : SQL query using the Count function in Access

We have been provided an Access database (Access I know, please dont shoot the messenger)

We have a need to extract the rows of data from a table, where data in a key column (imageID) is duplicated (occurs more than once) in the table.  

I am attempting to do this with the following SQL query and failing.  

**************************************************
SELECT imageID, year, seq_number, date
FROM table-name
GROUP BY imageID
HAVING COUNT(imageID) >1;
**************************************************

Can one of the SQL experts please assist? Many thanks!

Answer : SQL query using the Count function in Access

Sure you can use:Queries - NEW- Find Duplicate Query wizard
Follow the steps n the wizrds and you can view all duplicated records
for Example if mageID=1 and you have two rows- then the query will display two rows with identical imageID number
To delete just select one row and press DEL.

the sql code generated by the query will be :

SELECT [Table-name].imageID, [Table-name].year, [Table-name].seq_number, [Table-name].date
FROM [Table-name]
WHERE ((([Table-name].imageID) In (SELECT [imageID] FROM [Table-name] As Tmp GROUP BY [imageID] HAVING Count(*)>1 )))
ORDER BY [Table-name].imageID;

Hope this help
Random Solutions  
 
programming4us programming4us