Re: SQL COUNT(*) Function
Check this crosstab query .You can modify it according to your need
Code:
SELECT ID2,
count(case [Option] when 1 then 1 else null end) as [ID2-Option1],
count(case [Option] when 2 then 1 else null end) as [ID2-Option2]
FROM TEST where Option in(1,2)
GROUP BY ID2
Re: SQL COUNT(*) Function
does it work in Access too?
Re: SQL COUNT(*) Function
For creating crosstab query in Access Check for TRANSFORM syntax.
Check this
Code:
TRANSFORM Count(TEST.ID2) AS CountOfID2
SELECT TEST.ID2
FROM TEST
GROUP BY TEST.ID2
PIVOT "CountOfID2-" & TEST.Id2 In ("Option-1","Option-2","Option-3");
Re: SQL COUNT(*) Function
Thanks for your help...
I have seen that the columnname Option is being put in "[]" What does it mean? And how would the code if I would use another name like "IDOption"?
And can you explain this code please:
SELECT ID2,
count(case [Option] when 1 then 1 else null end) as [ID2-Option1],
count(case [Option] when 2 then 1 else null end) as [ID2-Option2]
FROM TEST where Option in(1,2)
GROUP BY ID2
Re: SQL COUNT(*) Function
Read about CrossTab Queries in SQL