2

Let's say I have a table:

| id | Name |
| 01 | Bob  |
| 02 | Chad |
| 03 | Bob  |
| 04 | Tim  |
| 05 | Bob  |

And I need to get the names which are mentioned only once (in this case: Chad and Tim) What is the query? Thanks.

IKo
  • 4,998
  • 8
  • 34
  • 54

2 Answers2

3

You could use:

SELECT Name
FROM table
GROUP BY Name
HAVING COUNT(*) = 1;

Rextester Demo

Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275
0

You can use HAVING clause, like:

SELECT NAME FROM table GROUP BY NAME HAVING COUNT(NAME) = 1
apomene
  • 14,282
  • 9
  • 46
  • 72