Mike Webb
Mike Webb

Reputation: 9003

Need help on a SQL select query in MS Access

I'm sure this question is fairly simple, but I am not very savvy when it comes to SQL queries. Here is an example table:

|Name  |N|
 --------
|Mike  |1|
|John  |2|
|Dave  |3|
|Jane  |1|
|Kyle  |2|
|Susan |4|
|Tim   |5|
|Joe   |5|
|Tina  |7|
|Carly |1|

I need to select all 'N' from this table that occurs only once. The result for this table should be 3, 4, and 7.

Upvotes: 0

Views: 116

Answers (2)

diagonalbatman
diagonalbatman

Reputation: 18002

SELECT distinct(N) FROM table_name;

Or am I missing the point?

Upvotes: 0

Andomar
Andomar

Reputation: 238086

You can use a having clause for that:

select  n
from    YourTable
group by
        n
having  count(*) = 1

Upvotes: 4

Related Questions