Hi everyone,
I can't seem to get this query right. It seems that crosstab queries don't support subqueries or is it? How should i rewrite this? It's too nasty to expand the whole query in four statements and union them together...
I can't seem to get this query right. It seems that crosstab queries don't support subqueries or is it? How should i rewrite this? It's too nasty to expand the whole query in four statements and union them together...
Code:
SELECT t1.companyname AS Supplier, t1.questionid, t1.Assigned, t1.Question, t1.Weight, c.CategoryName AS Category, t1.Score FROM ( SELECT s2.companyname, q.id as questionid, IIf((select count(*) from assignedquestions as aq where aq.assignedto=[MemberID] and aq.questionid=q.id )>0,"X","") AS Assigned, q.questionnumber as Question, q.questionweight as Weight, q.category as Category, (select score from score as s where s.teammemberid=[MemberID] and s.supplierid=s2.id and s.questionid=q.id) as Score FROM Question AS q, supplier AS s2 GROUP BY q.id, q.questionnumber, q.questionweight, q.category, s2.id, s2.companyname ) AS t1 LEFT JOIN Category AS c ON t1.Category = c.id;
Comment