1、聚合函数一般需要与group by一起使用,若分组列数与查询列数一致则效果与distinct相当。group by一般用于分组或与聚合函数配套使用,可以使用having加以条件限制。
使用模糊查询时为 like ‘%%’
2、四大连接:
使用限制:表之间的列数与列的数据类型需一致。
union:联合运算,返回由每个查询选择的所有的行,即为并集,查询结果进行了去重并进行了升序排列。in运算比union运算的优先级高。
union all:全联合运算,与union基本一致,但不去重也不排序。
intersect:交集,用相交运算返回多个查询中的公共行,升序排列。
minus:相减运算,求差集,去重,返回出现在第一个查询中但不出现在第二个程序中的数据;一般做相减运算时做两次并将两次的结果union all连接起来,因为做相减运算之前并不确定哪一个是数据量大。
select * from A minus select * from B
union all
select * from B minus select * from A
3、case when 表达式 then 值 else 值 end
select case when null is null then ‘1’ else ‘2’ 返回为1
其与 select decode (null,null,1,2)一致。