I have a table which has the raw data. In order to check for unwanted extra data I am trying to determine what id’s (tickerid is the column, earningsdata is the table) have more than 50 rows of data. It would have to loop through all the current ticker id’s (from a different table, earningstickers) and select only those id’s that have more than 50 rows of data. I can do a select * by id but I’m not sure how to iterate through all the id’s
Share
You can use
GROUP BYto group by eachtickerid, which will give you access to aggregate information related to eachtickeridsuch asCOUNT/SUM/AVG/etc…For your purposes, we must use
COUNT.Then the
HAVINGclause filters out thetickerids that have 50 rows or less:This will just give you a list of the
tickerids that have more than 50 rows, however if you want to display all rows and information of thetickerids that are in this list, you can join the table against this list by incorporating the above query into: