我们需要使用带有case子句的order by,因为用户可以从下拉列表中选择order的类型。。情况似乎还可以,直到还引入了一个整数值为wa的列。。似乎出于某种原因,mysql还假设整数列是字符串,并且排序也是一样的。。
以下是订货条款
order by (case when p_SortBy = 'Default' then CONVERT(st.IncrementNo, unsigned)
WHEN p_SortBy ='Program'
THEN st.StudyProgram
WHEN p_SortBy = 'Student'
then st.Name
when p_SortBy = 'Mobile'
then st.Mobile
END) asc
第一种情况(默认)是整数值,但排序是这样的 105,106,107,108,109,11,110
感谢您的帮助。。
1条答案
按热度按时间ctzwtxfj1#
你可以用多个
CASE
: