Steve writes "Interested to know the recommended approach to resolving this summary/pivot table requirement. I have a table of project issues that looks like:
issueID author owner assignee------- ------ ----- --------1 jon fred fred2 mary fred ralph3 yak ralph jane4 ralph yak janeetc
What I'm after is the summary counts for each person, in each role. Eg for the above data I'd like:
person numAuthored numOwned numAssigned------ ----------- -------- -----------jon 1 0 0fred 0 2 1mary 1 0 0ralph 1 1 1yak 1 1 0jane 0 0 2
The nearest I can get (by a series of select into/count statements, one for each field to summate) is:
person numAuthored numOwned numAssigned------ ----------- -------- -----------jon 1 NULL NULLmary 1 NULL NULLralph 1 NULL NULLyak 1 NULL NULLfred NULL 2 NULLralph NULL 1 NULLyak NULL 1 NULLfred NULL NULL 1ralph NULL NULL 1jane NULL NULL 2But this has duplicates in the person that somehow need to be 'collapsed' together.
Else there is a much better way of doing this?
TIA
Steve"