如下表,样例所示,code与eff均有为空的情况,如何将为空赋值为上一条不为空的值,如需求所示
12条回答 默认 最新
- 一把编程的菜刀 2022-10-20 09:00关注
SQ语句:
SELECT time,(select code from table2 where code<>'' and time<=t.time order by time desc LIMIT 1) as code ,(select eff from table2 where eff<>'' and time<=t.time order by time desc LIMIT 1) as eff FROM table2 t
结果如下:
测试用的数据如下:
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报