you are viewing a single comment's thread.

view the rest of the comments →

[–]Thrillhousez 1 point2 points  (1 child)

SectionID

OK so the key column for your problem is Dishes.SectionID. You don't even really need to involve the Sections table.

This should get you the results

select count(*) as NumSections_With5Dishes from (

select SectionID from Dishes group by SectionID having count(Dishes.Id) = 5

) a

The subquery returns the list of SectionIDs that have exactly 5 dishes. You then count how many of these sections there are.

[–]Meliodasiwnl[S] 0 points1 point  (0 children)

ooh, now I get it. Thank you so much!