I have a table which is formatted as:
id | food | userID | beerID
I am trying to select all the foods for a given beerID and a count of repeats. SO if there are 3 entries for pizza I get results like:
food | beerID | count
pizza | 34 | 2
hot wings | 34 | 1
pasta | 34 | 5
Does this work? I am a bit confused on using the count with the group by.
select food, beerID , count() where beerID = 34 group by food
GROUP BY: You should include in theGROUP BYclause all of the columns in theSELECTclause (and vice versa), the exception being any aggregate functions being applied to each group (such asCOUNT(*)).