Home > Software engineering >  How to select records with a count >30?
How to select records with a count >30?

Time:06-14

So I have this data set (down below) and I'm simply trying to gather all data based on records in field 1 that have a count of more than 30 (meaning a distinct brand that has 30 record entries) that's it lol!

I've been trying a lot of different distinct, count esc type of queries but I'm falling short. Any help is appreciated :)

Data Set

CodePudding user response:

By using GROUP BY and HAVING you can achieve this. To select more columns remember to add them to the GROUP BY clause as well.

SELECT * FROM your_table
WHERE Mens_Brand IN (SELECT Mens_Brand
FROM your_table 
GROUP BY Mens_Brand 
HAVING COUNT(Mens_Brand)>=30)
  • Related