数据库
首页 > 数据库> > db2笔记_5_特殊排序

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);

 

标签:排序,fcustno,fnum,tableName,笔记,FTIME,ftime,db2
来源: https://www.cnblogs.com/luyuting/p/16576024.html