文档库 最新最全的文档下载
当前位置:文档库 › sql试题

sql试题

将VF中默认目录指向订货管理1.

1.从职工关系中检索所有工资值

Select 工资from 职工

Select distinct 工资from 职工

2.检索仓库关系中的所有元组

Select * from 仓库

3.检索工资多于1230元的职工号

Select 职工号from 职工where 工资>1230

4.检索哪些仓库有工资多于1210元的职工

Select distinct 仓库号from 职工where 工资>1210

5.给出在仓库”WH1”或”WH2”工作并且工资少于1250元的职工号

Select 职工号from 职工;

Where 工资<1230 and (仓库号=”WH1” or 仓库号=”WH2”)

6.找出工资多于1230元的职工号和他们所在的城市

Select 职工号,城市from 职工,仓库;

Where (工资>1230) and (职工.仓库号=仓库.仓库号)

7.找出工作在面积大于400的仓库的职工号以及这些职工工作的城市

Select 职工号,城市from 仓库,职工;

Where (面积>400) and (职工.仓库号=仓库.仓库号)

8.那些城市至少有一个仓库的职工的工资为1250

Select 城市from 仓库where 仓库号in;

(select 仓库号from 职工where 工资=1250)

9.查询所有职工的工资都多于1210元的仓库的信息

Select * from 仓库where 仓库号not in;

(select 仓库号from 职工where 工资<=1210)

10.找出和职工E4挣同样工资的所有职工

Select 职工号from 职工where 工资=;

(select 工资from 职工where 职工号=”E4”)

11.检索出工资在1220元到1240元范围内的职工信息

Select * from 职工where 工资between 1220 and 1240(工资>=1220 and 工资<=1240) 12.从供应商关系中检索出全部公司的信息(不要工厂或其他供应商的信息)

Select * from 供应商where 供应商名like “%公司”

13.找出不在北京的全部供应商信息

Select * from 供应商where 地址!=”北京”

Select * from 供应商where not (地址=”北京”)

14.按职工的工资值升序检索出全部职工信息

Select * from 职工order by 工资(降序desc)

15.先按仓库号排序,再按工资排序输出全部职工信息

Select * from 职工order by 仓库号,工资

16.找出供应商所在地的数目

Select count (distinct 地址) from 供应商

17.求支付的工资总数

Select sum(工资) from 职工

18.求北京和上海的仓库职工的工资总和

Select sum(工资) from 职工where 仓库号in;

(select 仓库号from 仓库where 城市=”北京” or 城市=”上海”)

19.求所有职工的工资都多于1210元的仓库的平均面积

Select avg(面积) from 仓库where 仓库号not in;

(select 仓库号from 职工where 工资<=1210) 包含了尚没有职工的WH4仓库

Select avg(面积) from 仓库where 仓库号not in;

(select 仓库号from 职工where 工资<=1210);

And 仓库号in (select 仓库号from 职工)

20.求在WH2仓库工作的职工的最高工资值

Select max(工资) from 职工where 仓库号=”WH2”

21.求每个仓库的职工的平均工资

Select 仓库号, avg(工资) from 职工;

Group by 仓库号

22.求至少有两个职工的每个仓库的平均工资

Select 仓库号, count(*), avg(工资) from 职工;

Group by 仓库号having count(*)>=2

23.找出尚未确定供应商的订购单

Select * from 订购单where 供应商号is null

24.列出已经确定了供应商的订购单信息

Select * from 订购单where 供应商号is not null

25.检索那些仓库中还没有职工的仓库的信息

Select * from 仓库where not exists;

(select * from 职工where 仓库号=仓库.仓库号)

=

Select * from 仓库where 仓库号not in;

(select 仓库号from 职工)

26.检索那些仓库中至少已经有一个职工的仓库的信息

Select * from 仓库where exists;

(select * from 职工where 仓库号=仓库.仓库号)

= Select * from 仓库where 仓库号in;

(select 仓库号from 职工)

27.检索有职工的工资大于或等于WH1仓库中任何一名职工的工资的仓库号

Select distinct 仓库号from 职工where 工资>=any;

(select 工资from 职工where 仓库号=”WH1”)

=select distinct 仓库号from 职工where 工资>=;

(select min(工资) from 职工where仓库号=”WH1”)

28.检索有职工的工资大于或等于WH1仓库中所有职工的工资的仓库号

Select distinct 仓库号from 职工where 工资>=all

(select 工资from 职工where 仓库号=”WH1”)

= select distinct 仓库号from 职工where 工资>=;

相关文档