怎样写语句?

kinvs007 2009-11-08 05:25:19
怎样写语句?

1)查询所有职工工资都多于1210 元的仓库的信息。
2)查询向北京的供应商发出了订购单的仓库所在城市。
3)查询有职工工资大于或等于“WH1”仓库中所有职工工资的仓库号。
4)查询仓库中还没有职工的仓库信息。


仓库表
(仓库号)(城市)
(面积)(面积)


create table 职工表
(仓库号 char(10) ,
职工号 char(10)
工资 int )
)

create table 供应商表
(供应商号 char(10) ,
供应商名 char(10),
地址 char(20)
)

create table 订购单表
(订购单号 char(10) primary key,
供应商号 char(10),
职工号 char(10),
订购日期 datetime default getdate(),
...全文
91 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
cxmcxm 2009-11-09
  • 打赏
  • 举报
回复
--1)查询所有职工工资都多于1210 元的仓库的信息。 
select * from 仓库表 a where not exists(select * from 职工表 where 工资<=1210 and 仓库号=a.仓库号)
and exists(select * from 职工表 where 工资>1210 and 仓库号=a.仓库号)
--2)查询向北京的供应商发出了订购单的仓库所在城市。
select [城市] from 仓库表 a
where exists(select * from 职工表 b,供应商表 c,订购单表 d
where a.仓库号=b.仓库号 and b.职工号=d.职工号 and c.供应商号=d.供应商号 and c.地址='北京')
--3)查询有职工工资大于或等于“WH1”仓库中所有职工工资的仓库号。
select distinct a.仓库号 from 仓库表 a,职工表 b
where a.仓库号=b.仓库号
and b.工资>(select max(工资) from 职工表 where 仓库号='WH1')

--4)查询仓库中还没有职工的仓库信息。
select * from 仓库表 a where not exists(select * from 职工表 where 仓库号=a.仓库号)
kinvs007 2009-11-09
  • 打赏
  • 举报
回复
第一题和第四题不太行!
忆轩辕 2009-11-09
  • 打赏
  • 举报
回复
明显又是作业。。。。。。。。。
sinpoal 2009-11-09
  • 打赏
  • 举报
回复
-- my name is sinpoal


---- 不好意思哈。职工表取别名的格式错!
----特意修改!!

--2
select c.城市 from 仓库表 c ,职工表 z,订购单表 d, 供应商表 g
where (c.仓库号=z.仓库号 and z.职工号=d.职工号
and d.供应商号=g.供应商号 and g.供应商名='北京' )
--3
select c.仓库号 from 仓库表 c , 职工表 z --here
where z.工资 >=(select max(z.工资) from 仓库表 c inner join 职工表 z
on c.仓库号=z.仓库号
where c.仓库号='WH1')
--4
select c.仓库号 from 仓库表 c, 职工表 z --here
where not exists (select z.职工号 from 仓库表 c full join 职工表 z
on c.仓库号=z.仓库号 )
sinpoal 2009-11-09
  • 打赏
  • 举报
回复

-- my name is sinpoal


-- 第一题楼上的兄弟已经给你回答了哈--

--2
select c.城市 from 仓库表 c ,职工表 z,订购单表 d, 供应商表 g
where (c.仓库号=z.仓库号 and z.职工号=d.职工号
and d.供应商号=g.供应商号 and g.供应商名='北京' )
--3
select c.仓库号 from 仓库表 c , z.职工表
where z.工资 >=(select max(z.工资) from 仓库表 c inner join 职工表 z
on c.仓库号=z.仓库号
where c.仓库号='WH1')
--4
select c.仓库号 from 仓库表 c, z.职工表
where not exists (select z.职工号 from 仓库表 c full join 职工表 z
on c.仓库号=z.仓库号 )



luoyoumou 2009-11-08
  • 打赏
  • 举报
回复
---练习题???
SQL77 2009-11-08
  • 打赏
  • 举报
回复
1
SELECT * FROM TB T WHERE NOT EXISTS(SELECT 1 FROM TB WHERE SALARY<1210)

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧