Some data to test:
DECLARE @months TABLE
( month_id INT IDENTITY,
month_name VARCHAR(50)
)
INSERT INTO @months(month_name) VALUES ('April-09')
INSERT INTO @months(month_name) VALUES ('May-09')
DECLARE @awards TABLE
( award_id INT IDENTITY,
award_name VARCHAR(50)
)
INSERT INTO @awards(award_name) VALUES ('Bronze')
INSERT INTO @awards(award_name) VALUES ('Silver')
INSERT INTO @awards(award_name) VALUES ('Gold')
DECLARE @nominations TABLE
( fk_month_id INT,
fk_award_id INT,
other_field VARCHAR(10)
)
INSERT INTO @nominations(fk_month_id,fk_award_id,other_field) VALUES (1,1,'1')
INSERT INTO @nominations(fk_month_id,fk_award_id,other_field) VALUES (1,1,'2')
INSERT INTO @nominations(fk_month_id,fk_award_id,other_field) VALUES (2,2,'3')
INSERT INTO @nominations(fk_month_id,fk_award_id,other_field) VALUES (2,1,'4')
INSERT INTO @nominations(fk_month_id,fk_award_id,other_field) VALUES (3,1,'5')
INSERT INTO @nominations(fk_month_id,fk_award_id,other_field) VALUES (3,2,'6')
INSERT INTO @nominations(fk_month_id,fk_award_id,other_field) VALUES (3,2,'7')
And the query
SELECT month_name, award_name, ISNULL(cnt,0)
FROM @months
CROSS JOIN @awards
LEFT JOIN (
SELECT fk_month_id,fk_award_id, COUNT(*) AS cnt
FROM @nominations
GROUP BY fk_month_id,fk_award_id
) fk ON fk_month_id = month_id AND fk_award_id = award_id
The result is:
April-09 Bronze 2
April-09 Silver 0
April-09 Gold 0
May-09 Bronze 1
May-09 Silver 1
May-09 Gold 0