带计数和分组的请求

问题描述 投票:0回答:1

我有一张像这样的桌子:

id id_person id_equipment 约会
1 1 250 [日期_1]
2 2 250 [日期_2]
3 3 50
4 2 50 [日期_3]

我想要的是获取超过 1000 行且日期为空的每个人的 ID。

我试过:

select id_person  
from table 
where date is null
group by id_equipement 
having count(is_equipement) > 1000

我真的很不擅长 sql 请求,真的不知道它是否可行 不要认为这是重复的,因为我在写这个问题之前在这里搜索过

编辑(后代):
我使用了这个完美的请求

select id_personne,id_equipement,count(*)
from event_personne
group by id_equipement, id_personne  
having count(id_equipement) > 1000
order by count(*) desc 
sql rdbms
1个回答
1
投票

你可以试试这个,因为你需要出现超过1000次的人的id

select id_person  
from table 
where date is null
group by id_person
having count(id_person) > 1000
© www.soinside.com 2019 - 2024. All rights reserved.