ridgedawg - It's very hard to understand your question, but I'm guessing this is the kind of thing you're after...--datadeclare @t table (SUBID int, SID int, QID int, RESP varchar(10))insert @t select 400, 100, 1, 'TEXT'union all select 400, 100, 2, 'x'union all select 401, 100, 1, '..'union all select 402, 100, 1, '..'union all select 402, 100, 2, 'x'union all select 403, 100, 2, 'x'union all select 404, 100, 2, '..'union all select 400, 101, 1, 'a'union all select 400, 101, 2, 'b'--calculationselect SID, QID, RESP, count(*) as COUNTfrom ( select a.*, b.RESP from (select distinct a.SUBID, a.SID, b.QID from @t a, @t b) a --all questions for each SUBID & SID left outer join (select * from @t) b on a.SUBID = b.SUBID and a.SID = b.SID and a.QID = b.QID ) a --t but with additional 'null' answersgroup by QID, SID, RESPhaving SID = '100'order by SID, QID, RESP
Ryan Randallwww.monsoonmalabar.com London-based IT consultancy Solutions are easy. Understanding the problem, now, that's the hard part.