developer77
Programmer
Hi everyone,
I have a stored procedure that has the following sort by section and @SortColumn is one of the passed parameters:
ORDER BY
CASE @SortColumn
WHEN 1 THEN p.LastName
WHEN 2 THEN p.Address
WHEN 3 THEN p.Year
ELSE NULL
END,
p.Degree,
p.StudentID ASC
I would like to change it so that when 1 is passed in for @SortColumn, then it will sort by p.LastName, p.FirstName. I tried changing it what's below but get an error saying "incorrect syntax near ",". Is there a way for me to sort by more than one column if 1 is passed?
ORDER BY
CASE @SortColumn
WHEN 1 THEN p.LastName, p.FirstName
WHEN 2 THEN p.Address
WHEN 3 THEN p.Year
ELSE NULL
END,
p.Degree,
p.StudentID ASC
Thanks in advance..
I have a stored procedure that has the following sort by section and @SortColumn is one of the passed parameters:
ORDER BY
CASE @SortColumn
WHEN 1 THEN p.LastName
WHEN 2 THEN p.Address
WHEN 3 THEN p.Year
ELSE NULL
END,
p.Degree,
p.StudentID ASC
I would like to change it so that when 1 is passed in for @SortColumn, then it will sort by p.LastName, p.FirstName. I tried changing it what's below but get an error saying "incorrect syntax near ",". Is there a way for me to sort by more than one column if 1 is passed?
ORDER BY
CASE @SortColumn
WHEN 1 THEN p.LastName, p.FirstName
WHEN 2 THEN p.Address
WHEN 3 THEN p.Year
ELSE NULL
END,
p.Degree,
p.StudentID ASC
Thanks in advance..