在MS访问中需要SQL select查询的帮助

时间:2021-11-14 02:02:03

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:

我确信这个问题相当简单,但是对于SQL查询,我不是很在行。下面是一个示例表:

|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.

我需要从这个只出现一次的表中选择所有的'N'。这个表的结果应该是3 4 7。

2 个解决方案

#1


4  

You can use a having clause for that:

你可以使用“拥有”条款:

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

#2


0  

SELECT distinct(N) FROM table_name;

选择不同的从table_name(N);

Or am I missing the point?

还是我没有抓住要点?

#1


4  

You can use a having clause for that:

你可以使用“拥有”条款:

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

#2


0  

SELECT distinct(N) FROM table_name;

选择不同的从table_name(N);

Or am I missing the point?

还是我没有抓住要点?