mysql 有没有类似 oracle lag函数

2024-11-01 02:27:54
推荐回答(1个)
回答1:

find_in_set这个函数不错,可惜Oracle中没有,但是我们可以变相应用,同样可以起到相同的效果。

select
decode(teii.item_num,'GMEXIN10484',1,'HXEXIN10472',2,'HXEXIN10471',3,'GMEXIN10487',4,'GMEXIN10483',5) sequence ,
teii.*
from t_exam_item_info teii
where teii.item_num in ( 'GMEXIN10484','HXEXIN10472','HXEXIN10471','GMEXIN10487','GMEXIN10483' )
order by decode(teii.item_num,'GMEXIN10484',1,'HXEXIN10472',2,'HXEXIN10471',3,'GMEXIN10487',4,'GMEXIN10483',5) ;