SQL LanguageSQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Select
Z.id ZoneID,
count(case when p.type = 'Type A' then 1 else null end) TypeACount,
count(case when p.type = 'Type B' then 1 else null end) TypeBCount,
count(1) TotalCount
from
Zone Z inner join Tag t on z.id = t.zoneid
Inner join Prop p on z.propid = p.id
Group by
z.id
but here's another thing... if a zone has zer0 of typeA and typeB, the record for that zone wont be shown, is there something i can add for it to display '0' for typeACount and typeBCount instead of NOT showing up at all?