select 职工号 from 职工e where 月工资=(select max(月工资) from 职工 as m where m.部门号=e.部门号) ---你的貌似可以换成下面的 select 职工号,max(月工资) from 职工e group by 职工号
select 1 from 职工 where a.姓名=姓名 and a.月工资>月工 其中1是代表什么呀?
1.select 职工号 from 职工 where 月工资=(select max(月工资) from 职工 group by 部门号) 2.select 姓名,年龄,月工资 from 职工 where 年龄 >45 Union all select 姓名,年龄,月工资 from 职工 where 月工资<10000
1.查询每个部门中月工资最高的“职工号”的SQL查询语句如下: select 职工号 from 职工e where 月工资=(select max(月工资) from 职工 as m where m.部门号=e.部门号)跟据你的题意得: select 职工号 from (select 职工号, max(月工资) from 职工e group by 部门号) A从查查询结果得到结果中得到职工号比用条件查询要快。 2.假定分别在“职工”关系中的“年龄”和“月工资”字段上创建索引,如下查询语句可能不会促使查询优化器使用索引,从而降低查询效率,请写出既可以完成相同功能又可以提高查询效率的语句。 select 姓名,年龄,月工资 from 职工 where 年龄 >45 or 月工资<10000可改写: select 姓名,年龄,月工资 from 职工 where 年龄 >45 union all select 姓名,年龄,月工资 from 职工 where 月工资<10000
职工 as m where m.部门号=e.部门号)
---你的貌似可以换成下面的
select 职工号,max(月工资) from 职工e
group by 职工号
其中1是代表什么呀?
2.select 姓名,年龄,月工资 from 职工 where 年龄 >45
Union all
select 姓名,年龄,月工资 from 职工 where 月工资<10000
select 职工号 from 职工e where 月工资=(select max(月工资) from
职工 as m where m.部门号=e.部门号)跟据你的题意得:
select 职工号 from (select 职工号, max(月工资) from 职工e group by 部门号) A从查查询结果得到结果中得到职工号比用条件查询要快。
2.假定分别在“职工”关系中的“年龄”和“月工资”字段上创建索引,如下查询语句可能不会促使查询优化器使用索引,从而降低查询效率,请写出既可以完成相同功能又可以提高查询效率的语句。
select 姓名,年龄,月工资 from 职工 where 年龄 >45 or 月工资<10000可改写:
select 姓名,年龄,月工资 from 职工 where 年龄 >45
union all select 姓名,年龄,月工资 from 职工 where 月工资<10000