Reputation: 555
I'm looking for something other than DISTINCT because with distinct you would return $2.90, $4.78, $1.99. $6.22 with the given column below in a table (let's say table groceries).
SELECT DISTINCT price
FROM groceries
For example if the whole price column has values:
price:
$2.90
$4.78
$1.99
$6.22
$1.99
$2.90
I just want the values that are unique only. So the return would be: $4.78 $6.22
How can I do this with not using unique keys and also DISTINCT?
Upvotes: 1
Views: 581
Reputation: 41
Select value from table group by value having count (value)=1
Hope this helps.
Upvotes: 1
Reputation: 7200
Try this one
SELECT price
FROM groceries
GROUP BY price
HAVING COUNT(*) = 1
Upvotes: 1
Reputation: 10565
This will give you unique set of price
:
SELECT * FROM (SELECT COUNT(price) pricecount, price FROM groceries GROUP BY price) a WHERE a.pricecount = 1;
Upvotes: 1