读书人

子查询返回值多于一个的有关问题。

发布时间: 2013-06-19 10:26:41 作者: rapoo

子查询返回值多于一个的问题。。。
查找财务部年龄低于开发部员工年龄的员工的姓名。

select name from employees where birthday in (select birthday from employees where departmentid in (select departmentid from departments where departmentname = '财务部'))
and ((select birthday from employees where departmentid in (select departmentid from departments where departmentname = '财务部'))
>all (select birthday from employees where departmentid in (select departmentid from departments where departmentname = '开发部')))
[解决办法]

引用:
查找财务部年龄低于开发部员工年龄的员工的姓名。

问题本身就有BUG
查找财务部年龄低于开发部员工平均年龄的员工的姓名。
查找财务部年龄低于开发部员工最高年龄的员工的姓名。
查找财务部年龄低于开发部员工最低年龄的员工的姓名。

读书人网 >SQL Server

热点推荐