Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Request with count and group by

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading