On 2005 SQL Server Express I am trying to get a sql statement working where it showing unique values where the value serial number was only entered ONCE in the table. If the user would enter a serial number twice I want it to just ignore both records But I am not sure how to accomplish it. I tried this with distinct but it would still show a record.
SELECT DISTINCT SerialNumber, ModelNumber, Date, CustomerName
FROM PreQcFormTable
WHERE (Date BETWEEN '2/24/2014' AND '3/5/2014') AND (ProductOrigin = 'P') AND (FailCodes = '')
It doesn't take into account that the SerialNumber might have been inputed twice or that the SerialNumber is in more then one record. Is there something else I need to add to this to make it ignore None unique SerialNumber?
Edit 1 when I use this sql statement i would get this record
"5554432218 7200A-70N 2014-03-04 00:00:00.000 CPE"
"555555 9200A-7E1100 2014-03-05 00:00:00.000 ACP"
"89701234555 9200B-7E1100 2014-02-25 00:00:00.000 Gleen"
Issue is the 55555 Serial number has been entered already within the week when I enter this similar sql statement.
SELECT *
FROM PreQcFormTable
WHERE (Date BETWEEN '2/24/2014' AND '3/5/2014') AND (ProductOrigin = 'P') AND (FailCodes != '')
results:
555555 9200A-7E1100 2014-03-05 00:00:00.000 ACP 2M is: 89
1323465 7200A-70N 2014-02-25 00:00:00.000 ACP 1M
Knowing that I want the record removed from the first one where it would lead me to this result:
"5554432218 7200A-70N 2014-03-04 00:00:00.000 CPE"
"89701234555 9200B-7E1100 2014-02-25 00:00:00.000 Gleen"