annieko
07-12-2007, 06:18 AM
Hi guys,
I've got a query like this:
SELECT userID, invoiceID, count(distinct productID) AS product_count
From SALES
which will return results like:
userID invoiceID product_count
------ -------- -----------
0209 INV001 1
0207 INV006 1
0202 INV001 3
And I just want the records with product_count = 1, how can I do this?
I thought about putting the result in a temp table and then do my query again, but is there a quicker way of doing this?
I've got a query like this:
SELECT userID, invoiceID, count(distinct productID) AS product_count
From SALES
which will return results like:
userID invoiceID product_count
------ -------- -----------
0209 INV001 1
0207 INV006 1
0202 INV001 3
And I just want the records with product_count = 1, how can I do this?
I thought about putting the result in a temp table and then do my query again, but is there a quicker way of doing this?