高手帮忙优化以下sql语句 select 职工号 from 职工 E where 工资=(select max(工资) from 职工 as M where M.部门号=E.部门号) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 TRY:select 职工号 from 职工 Ewhere NOT EXISTS (select 1 from 职工 as M where M.部门号=E.部门号 AND M.工资>E.工资) select 职工号 from 职工 Ewhere 工资=(select top 1 工资 from 职工 as M where M.部门号=E.部门号 order by 工资 desc) select 职工号 from 职工 E where exists(select * from 职工 as M where M.部门号=E.部门号 and M.工资>E.工资) SELECT 职工号 FROM 职工 EWHERE NOT EXISTS (SELECT 1 from 职工 WHERE 部门号=E.部门号 AND 工资>E.工资) select 职工号 from 职工 Ewhere NOT EXISTS (select 1 from 职工 as M where M.部门号=E.部门号 AND M.工资>E.工资) 理论上,用not exists最快的可以试下:select E.职工号 from 职工 E left join 职工 Mon M.部门号=E.部门号 AND M.工资>E.工资where M.职工号 is null 我的数据库记录太少,看不到查询耗费的时间。能解释一下为什么not exists最快吗? select E.职工号 from 职工 E left join 职工 Mon M.部门号=E.部门号 AND M.工资>E.工资where M.职工号 is null是对的可是为什么要用where M.职工号 is null啊?这块不太明白谢谢,给说一下吧 SQL游标问题 用ASP 调用存储过程出错 把字段名用变量为何不能插入?如 SQL高手快来帮忙啊!!! 数据库日志错误 如何获取进程正在查询的SQL语句? 比较麻烦的SQL 救命:这个SELECT语句怎么写 难题求解,分不够开贴再加,谢谢! to 邹建 以下是联机sql Server帮助的一段示例代码,理解不了,请帮忙!! SQL Server2005怎么样安装在windows XP上面?
select 职工号 from 职工 E
where NOT EXISTS (select 1 from 职工 as M where M.部门号=E.部门号 AND M.工资>E.工资)
where 工资=(select top 1 工资 from 职工 as M where M.部门号=E.部门号 order by 工资 desc)
where exists(select * from 职工 as M where M.部门号=E.部门号 and M.工资>E.工资)
FROM 职工 E
WHERE NOT EXISTS (SELECT 1 from 职工 WHERE 部门号=E.部门号 AND 工资>E.工资)
where NOT EXISTS (select 1 from 职工 as M where M.部门号=E.部门号 AND M.工资>E.工资)
select E.职工号 from 职工 E left join 职工 M
on M.部门号=E.部门号 AND M.工资>E.工资
where M.职工号 is null
on M.部门号=E.部门号 AND M.工资>E.工资
where M.职工号 is null
是对的
可是为什么要用where M.职工号 is null啊?
这块不太明白
谢谢,给说一下吧