sql 语言中如何查询

来源:百度知道 编辑:UC知道 时间:2024/05/17 20:42:03
比如我想查询工资在前6位但是纳税不是前6位的人,有张职工表,和一张职工纳税表,请教了

select top 6 * from 职工表 where 职工号 not in (select top 6 职工号 from 纳税表 order by 纳税金额 desc) order by 工资 desc

你试一下

select top 6 * from 职工表,纳税表 where 职工表.工号=纳税表.工号 order by 纳税表.工资

大概思路就是这样吧!

select top 6 * from 职工表 a
where not exists(
select 1 from (select top 6 * from 纳税表) b where a.职工号=b.职工号)

你试试

同上。。

错了