How to select only values that are not repeating in a column? For example if a have table with following values I expect to return only the id
value of b
:
id
--
a
b
c
a
c
CodePudding user response:
Aggregation provides one approach:
SELECT id
FROM yourTable
GROUP BY id
HAVING COUNT(*) = 1;
CodePudding user response:
In subselecet you select values which have only one record, Than in outer select you search for all datas based on that value in subselect
SELECT *
FROM table
WHERE id IN (SELECT id
FROM table
GROUP BY id
HAVING COUNT (id) = 1)