I have a table like:
| id | id_person | id_equipement | date |
|---|---|---|---|
| 1 | 1 | 250 | [date_1] |
| 2 | 2 | 250 | [date_2] |
| 3 | 3 | 50 | null |
| 4 | 2 | 50 | [date_3] |
what I want is to get the id of every person for which there is more than 1000 line and the date is null.
I tried with :
select id_person
from table
where date is null
group by id_equipement
having count(is_equipement) > 1000
I’m really bad at sql request and don’t really know what if it’s doable or not
Don’t think it’s a duplicate as I searched here before writing this question
EDIT (for posterity) :
I used this request which works perfectly
select id_personne,id_equipement,count(*)
from event_personne
group by id_equipement, id_personne
having count(id_equipement) > 1000
order by count(*) desc
>Solution :
You can try this as you need the id of persons appearing more than 1000 times
select id_person
from table
where date is null
group by id_person
having count(id_person) > 1000