icarus5000
Technical User
Hi,
I'm trying to create a sproc that is using parameters for dynamic field names. The following sql statement is causing problems with using the sproc parameters in the GROUP BY clause. Is there a way around this apart from writing an IF statement for each field iteration.
SELECT @group1,@group2,CRS_ID,COUNT(STATUS) as status_total
FROM TBLMAIN
WHERE STATUS='C' AND COMP_ID=@CompID
GROUP BY @group1, @group2, CRS_ID
Thanks,
Ic
I'm trying to create a sproc that is using parameters for dynamic field names. The following sql statement is causing problems with using the sproc parameters in the GROUP BY clause. Is there a way around this apart from writing an IF statement for each field iteration.
SELECT @group1,@group2,CRS_ID,COUNT(STATUS) as status_total
FROM TBLMAIN
WHERE STATUS='C' AND COMP_ID=@CompID
GROUP BY @group1, @group2, CRS_ID
Thanks,
Ic