I have a query like this:
SELECT
ROW_NUMBER() OVER(ORDER BY USER_FNM, USER_LNM) AS ROW_NUM,
USER_TEL, USER_FAX, USER_MOB
FROM
BAUSER
ORDER BY
CASE
WHEN @cOrderBy = 'USER_FNM_USER_LNM ASC' THEN USER_LNM
END ASC,
CASE
WHEN @cOrderBy = 'USER_FNM_USER_LNM DESC' THEN USER_LNM
END DESC,
CASE
WHEN @cOrderBy IS NULL THEN USER_KEY
END ASC
OFFSET @iStartIndex ROWS
FETCH NEXT @iRowsPerPage ROWS ONLY
What I would like to do is sorting by two columns - but this is showing syntax error:
CASE WHEN @cOrderBy = 'USER_FNM_USER_LNM ASC' THEN USER_LNM, USER_FNM END ASC
Any idea how to sort by two columns in this case?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…