Hi everyone.
Doesn't it work with order by alias bound to the parameter?
My order by:
ORDER BY CASE
WHEN @ordercolumn = 'Id' THEN Id
WHEN @ordercolumn = 'Username' THEN Username
END
I get error "Ambiguous column name 'Id'"
My select:
SELECT DISTINCT P.Id,
P.Username Username,
………
I can't post the whole code because it's 150 lines but there are no other Id columns in the selection