那不如果没有规律,仅仅是你“希望”,那可能要穷举了,order by case when 最后两位为01 then 1 when 03 then 2 when 02 then 3 when xxxx这样。
按第三个字段排序可行,重复值可以这样处理: select item_no ,item_name from tb a where exists (select 1 from (select item_no ,item_name,max(时间列) 时间列 from tb group by item_no ,item_name)b where a.item_no =b.item_no and a.item_name=b.item_name and a.时间列=b.时间列) order by 时间列
item_no item_name
W2014-01 测试1
W2014-02 测试2
W2014-03 测试3我希望是这样排序的
item_no item_name
W2014-01 测试1
W2014-03 测试3
W2014-02 测试2
select item_no ,item_name
from tb a
where exists (select 1 from (select item_no ,item_name,max(时间列) 时间列 from tb group by item_no ,item_name)b
where a.item_no =b.item_no and a.item_name=b.item_name and a.时间列=b.时间列)
order by 时间列