I need to return the count of remaining items among rows of the same type. Here's a starting SELECT statement:
[last_sticker_no] - [next_sticker_no] + 1 AS remaining_stickers,
INNER JOIN CampaignYear ON InspectionStickers.fk_campaign_year = CampaignYear.pk_campaign_year)
INNER JOIN InspectionType ON CampaignYear.fk_inspection_type = InspectionType.pk_inspection_type
AND InspectionType.pk_inspection_type = 1
AND CampaignYear.pk_campaign_year = 4
The statement returns the number of unused sticker numbers in each row having a status of 'C' for inspection type 1 by campaign year (4 in this example).
I need to add to that count the number of unused sticker numbers in other rows having a status of 'N' with the same inspection type and campaign year. I'm sure I need a sub SELECT, but I don't know how to structure it. Any help would be greatly appreciated! Pete