我有以下简单查询:
SELECT * FROM grade order by GRADENAME
输出:
这是一个主要在用户体验部分的问题,因为他收到<select></select>
元素的成绩,如上面的列表所示。我有没有办法让他们从1A
开始一直显示11D
?有可能这样做吗?
应用SELECT * FROM grade order by BIN(GRADENAME);
结果:
答案 0 :(得分:1)
试试这个
SELECT * FROM grade order by BIN(GRADENAME);
答案 1 :(得分:1)
可能是这样的
SELECT * FROM grade
Order By Cast(SubString(GRADENAME,1,Length(GRADENAME) -1 As Int),Right(GRADENAME,1)
或者
SELECT * FROM grade
Order By lpad(GRADENAME, 10, 0)
答案 2 :(得分:0)
试试这个
SELECT GRADEID,
GRADENAME
FROM GRADE
GROUP BY GRADENAME
ORDER BY 2;