sql基础
if判断 --case when
select
课节,
max(case 周 when 周一 then 学科 else ‘’ end)
from
课程表
group by 课节
如果周的这一列是周一就显示学科,否则显示‘’。
top-N分析
分页oracle 用的rownum 伪列, 会把查到的数据前面加一列序号。
select rownum ,t.*from emp t where rownum<=2
select rownum ,t.*from emp t where rownum=2
rownum 是运行时动态添加的列,直接去查询第二列 查不到。
select * from(select rownum as nu ,t.*from emp t where rownum<=2) where nu=2;
先把rownum排好,然后在取第二条。<