龙_王
2018-04-05 23:06
--1
Select
(Select Count(*) From emp)total,
(Select Count(*) From emp Where to_char(hiredate,'yyyy')='1980') "1980",
(Select Count(*) From emp Where to_char(hiredate,'yyyy')='1981') "1981",
(Select Count(*) From emp Where to_char(hiredate,'yyyy')='1982') "1982",
(Select Count(*) From emp Where to_char(hiredate,'yyyy')='1987') "1987"
From dual;
--2
Select um(Decode(to_char(hiredate,'yyyy'),'1980',1,0)) "1980",
Sum(Decode(to_char(hiredate,'yyyy'),'1981',1,0))"1981",
Sum(Count(*) totla ,
SDecode(to_char(hiredate,'yyyy'),'1982',1,0)) "1982",
Sum(Decode(to_char(hiredate,'yyyy'),'1987',1,0)) "1987"
From emp ;
sql标准格式 select * from 表
1表全用的子查询查出了结果 ,最后不需要from表了,就必须用伪表dual来满足格式需要了
Oracle的伪表,因为select 需要对象
Oracle高级查询
62862 学习 · 144 问题
相似问题
回答 1
回答 1