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

来源:5-4 案例3

龙_王

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 ; 


写回答 关注

2回答

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

    sql标准格式  select * from 表  

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

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

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

Oracle高级查询

数据库开发中应用广泛的高级查询,本教程通过大量的案例详细讲解

62884 学习 · 144 问题

查看课程

相似问题