【问题标题】:Nested query sql hospital嵌套查询sql医院
【发布时间】:2023-02-09 19:30:21
【问题描述】:
select Fname,Lname,salary,ssn
from Employee
where joptype='nurse' AND salary <= ALL (select salary
from Employee E,Nurses N
where E.Ssn=N.Ssn AND E.joptype='nurse' AND N.shift='morning');

我想返回一份早上工作的护士名单,他们的工资低于所有护士,或者相反。我早晚都试过,而且我试过的比所有护士都多。我认为问题出在第二个地方,他似乎忽略了轮班条件。

【问题讨论】:

标签: sql oracle


【解决方案1】:

我是这样理解的;你说的:

他们的薪水低于所有护士

可能意味着他们的平均工资,所以我在子查询中使用了它。

select *
from employee e 
where joptype = 'nurse'
  and shift = 'morning'
  and salary < (select avg(salary)         --> average salary of all nurses
                from employee
                where joptype = 'nurse'
               ); 

(只是一句话:真的是乔p类型?这不是一个工作吗b?)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-21
    • 2016-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多