chris123321
IS-IT--Management
A user has a drop-down list in which he can decide how to Group By a report. And the Group-By of the report depends on the Order By clause of the stored procedure. So for each of the different selections in the dropdownlist, the report will look different.
The best solution I found is using a case statement from:
Any other suggestions?
The best solution I found is using a case statement from:
Code:
DECLARE @col VARCHAR(9)
SET @col = 'firstname'
IF @col IN ('firstname', 'email')
SELECT * FROM blat
ORDER BY CASE @col
WHEN 'firstname' THEN firstname
WHEN 'email' THEN email
END
ELSE
SELECT * FROM blat
GO
Any other suggestions?