聚集函数如max,min,sum,count,avg不能出现在where子句中,要想加条件,必须用having
select pub,sum(price*qty) from books group by pub having sum(price)>60;
nvl函数的使用:
select nvl(name,'未输入') from table;
查询字段是否为空
decode的使用:
select sum(decode(sex,'男',1,0)) 男人数,sum(decode(sex,'女',1,0)) 女人数 from student;
统计男生人数和女生人数