I have a customer database and i’m looking to run a query to find any barcode that was used more than once in a day and output just the barcode… So for example if barcode #1 was scanned 3 times on a specific date it will show 3 transactions in the database all with the barcode #1… Here is a basic query I have now searching by date…
Select *
FROM Customers
WHERE (dtCreated BETWEEN CONVERT(DATETIME, '2012-12-10 00:00:00', 102) AND CONVERT(DATETIME, '2012-12-11 00:00:00', 102)) AND (sBarcode = '1')
Instead of searching for barcode 1, i’d like to know ANY barcodes (sBarcode) that was scanned more than once on 12/10/12.
select barcode, count(barcode) as cnt from table_name where date = desired_date group by barcode HAVING (COUNT(*) > 1)