需要 MS Access 查询

MS Access query required

我在table“customer”中有数据

ID    NAME    CITY
11    John     A
12    Peter    B
13    Robin    A
14    Steve    C
15    Methew   D
16    Matt     C
17    Nancy    C
18    Oliver   D

我想要的查询只显示同一城市的每 2 个客户的数据。

Output should be,


ID    NAME    CITY
11    John     A
13    Robin    A
15    Methew   D
18    Oliver   D

试试这个

select * from Customer where City IN (
 select  city  from Customer as c
  group by city having Count(City) = 2)

以下查询执行此操作

select a.ID1,a.Name1,a.City,b.cnt_of_customers
from Customers as a
        ,(   SELECT City ,count(*) as cnt_of_customers
              FROM Customers
           GROUP BY  City 
          HAVING count(*)=2) as b
where a.city=b.city