db2笔记_5_特殊排序

根据fcustno分类,按ftime排序(不同的fcustno,fnum从1开始算)

取fcustno和对应的最大ftime:

select * from (
  SELECT FCUSTNO,FTIME,row_number() over(partition by FCustNo order by FTIME desc) fnum from tableName
) where fnum=1;

自定义排序

select * from tableName where colName in(1, 2, 3) order by  decode(colName, 2, 1, 1, 2, 3);

 

posted @ 2022-08-11 14:51  LuLuYaa  阅读(60)  评论(0)    收藏  举报