jeudi 5 mars 2015

How to count number of rows that has a certain amount of duplicates

I have an SQLite database with alot of messages, each with an unique messageid, and an non unique userid. I want to specifically count how many different userid's that has, say fewer than 40 messages. How would I do that?


The following give me the specific messages I want, but I just want to know how many they are.



select userid, count(*) as c from MessageType1 group by userid having c <40 order by c desc;


Ideally I would also love to get a plot of the number of messages for each of userid. Sorry if two questions is to much.


Aucun commentaire:

Enregistrer un commentaire