【每日一题】SQL 知识大测验 | 持续更新
---11. 如果是oracle,想到的就是pivot行专列,listagg合并多个到一个字段内
select aaa, nvl(周一, '无课') as 周一, nvl(周二, '无课') 周二, nvl(周三, '无课') 周三, nvl(周四, '无课') 周四, nvl(周五, '无课') 周五 from (select '上午' as aaa, a.week, a.class_name from lx_11 a where a.morning = '有课' union all select '下午' as aaa, a.week, a.class_name from lx_11 a where a.afternoon = '有课') pivot(listagg( class_name, ',') within group(order by class_name) for week in('周一' as 周一, '周二' AS 周二, '周三' AS 周三, '周四' AS 周四, '周五' AS 周五));
--12
select * from lx_12 a, lx_12 b where a.redate = b.redate -1 and a.temp
--13 --如果是Oracle就是判断row_number()、rank()、dense_rank() 的区别
select a.score, dense_rank() over(partition by a.aa order by a.score desc) from (select '1' as aa, score from lx_13) a
赞0
踩0