ASP 里order by,按两个条件排名?

来源:百度知道 编辑:UC知道 时间:2024/05/13 07:13:30
a表里有两个字段 time 和 pm
如果pm为空就按照time降序排,如果pm不为空,就按照pm里的数字降序排,pm排序优先,其次是按照time时间排。
不好意思,忘记说了,我是ACCESS数据库!

select * from [a] order by case [pm] when null then [time] else [pm] end desc

sqlserver查询分析器中测试通过,不知你用的什么数据库。
----------------------
access啊,我不熟。
测了一下,上面那句的语法在access中通不过。帮不上你了,不行的话,就按照linkon3说的那样处理吧,反正在ASP中也不费事。

这个我觉得用if else比较好,否则不好搞
if pm="" then
sql="select * from xxx where xxx=xxx order by time"
else
sql="select * from xxx where xxx=xxx order by pm,time"