编写一个sql语句,只有当工资少于5000,而且最高工资超过15000时,才显示部门ID
以及该部门支付的最低工资和最高工资。。
【以下是表结构】emp_id         number(5)   not   null
last_name   varchar2(30)   not   null
first_name   varchar2(30)
dept_id   number(2)
job_cat   varchar2(30)
salary   number(8,2) 求大侠们指教,能不能说的清楚些,太急了啊~,谢谢啊

解决方案 »

  1.   


    SQL> create table t3(
      2    emp_id          number(5) not  null,
      3    last_name       varchar2(30)  not null,
      4    first_name      varchar2(30),
      5    dept_id       number(2),
      6    job_cat       varchar2(30),
      7    salary       number(8,2)
      8  );Table createdExecuted in 0.016 secondsSQL> insert into t3 select 1,'a','',10,'',4000 from dual
      2  union
      3  select 2,'b','',11,'',8000 from dual
      4  union
      5  select 3,'b','',12,'',18000 from dual;3 rows insertedExecuted in 0.015 secondsSQL> select emp_id,last_name,case when salary<5000 then null when salary>=15000 then null else dept_id end deptid,salary from t3;EMP_ID LAST_NAME                          DEPTID     SALARY
    ------ ------------------------------ ---------- ----------
         1 a                                            4000.00
         2 b                                      11    8000.00
         3 b                                           18000.00Executed in 0.016 seconds
      

  2.   

    什么对不住啊,没说清楚,这个题的要求之用一般查询,不涉及PL/SQL,你说说我,哎,实在是没辙了大家帮帮忙,只要能给个大概的就可以了拜谢中.................
      

  3.   

    大哥,这个难道不是一般的SQL?select emp_id,last_name,case when salary<5000 then null when salary>=15000 then null else dept_id end deptid,salary from t3;
    faint,faint.....你所谓的一般是什么?
      

  4.   

    就是不用PL/SQL丫,没有控制语句嘛