问答详情
源自:5-4 案例3

1中为什么from dual这个系统表?

--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 ; 


提问者:龙_王 2018-04-05 23:06

个回答

  • 慕田峪9362115
    2019-06-04 10:21:02

    sql标准格式  select * from 表  

    1表全用的子查询查出了结果 ,最后不需要from表了,就必须用伪表dual来满足格式需要了

  • siriusmath
    2018-05-16 22:37:28

    Oracle的伪表,因为select 需要对象