I have a table on which I'd like to count how many offers have been made. However, this has a few conditions:- cap_stac MUST equal 'A'If cap_dec2 IS NULL AND cap_dec1 = 'U' Then Count theseIF cap_dec1 IS NULL AND cap_dec2 = 'U' Then count theseI'm getting OK results back with the query below but I need it to only return one row for each instance of cap_ayrc, cap_crsc, cap_blok, cap_occl and cap_stac.SELECT DISTINCT cap_ayrc, cap_crsc, cap_blok, cap_occl, cap_stac, CASE WHEN ((cap_dec2 IS NULL) AND (cap_dec1 = 'U')) THEN COUNT(cap_dec1) WHEN ((cap_dec1 IS NULL) AND (cap_dec2 = 'U')) THEN COUNT(cap_dec2) ELSE 0 END AS UOffersFROM dbo.srs_capGROUP BY cap_ayrc, cap_crsc, cap_blok, cap_occl, cap_stac, cap_dec1, cap_dec2HAVING (cap_stac = 'A') OR (cap_stac = 'A')
this query outputs the following:- 2003/4 ACCA F1 A A 0 2003/4 ACCA F1 A A 3
when I want it to output:-2003/4 ACCA F1 A A 3
Help, please 