Firmeza Firmeza - 1 year ago 102
SQL Question

sql SELECT query not doing the opposite

im using a query that checks for duplicate values, but now i want it to do the opposite of this query:

SELECT * FROM orders WHERE buy_date (SELECT buy_date FROM orders GROUP BY buy_date HAVING count(*)>1)

Result: result

I tried changing
HAVING count(*)=0 / HAVING count(*)<1
put it returns nothing

Answer Source

The limiting clause having count(*) < 1 will not return values. You cannot return a recordset with half a row! Try HAVING count(*) < 2 which will return rows with a count of 1.

You may also want to check out the DISTINCT function which returns distinct values.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download