全部sql以access2007为标准.均测试通过
1:查询全部入库产品的编号和数量
select 产品编号,sum(入库数量) as 入库总数量 from 入库数据 group by 产品编号
2:查询全部产品的入库信息
select * from 入库数据
3:查询全部出库产品的出库总价,要求查询结果为两列,为 “产品编号”“出库总价”
select 产品编号,sum(出库单价*出库数量) as 出库总价 from 出库数据 group by 产品编号
4:查询入库的产品编号(即结果要求不重复)
select distinct(产品编号) from 入库数据
5:查询入库单价大宇20 元的产品编号和入库日期
select 产品编号,入库日期 from 入库数据 where 入库单价 > 20
6:查询入库单价在10 元到100 元之间的产品编号
select 产品编号 from 入库数据 where 入库单价 > 10 and 入库单价 < 100
7:查询产品编号为三个字的产品入库信息
select * from 入库数据 where 产品编号 in (select 产品编号 from 产品信息 where len(产品名称)=3)
8:查询龙井茶的入库信息
select * from 入库数据 where 产品编号 in (select 产品编号 from 产品信息 where 产品名称=’龙井茶’)
9:查询缺少产品说明的产品信息
select * from 产品信息 where 产品说明 is null
10:查询入库单价为5 元且入库数量为10 的产品编号
select 产品编号 from 入库数据 where 入库单价=5 and 入库数量=10
11:查询入库数量超过20的产品入库信息,查询结果按照入库单价进行降序排列
select * from 入库数据 where 入库数量 > 20 order by 入库单价 desc
12:查询出库产品类别总数
select count(*) as 类别数量 from (select distinct 产品信息.类别id from 出库数据,产品信息 where 出库数据.产品编号=产品信息.产品编号)
13:查询最大出库单价的产品出库信息
select top 1 * from 出库数据 order by 出库单价 desc
14:查询入库数量超过100 的产品编号和入库单价
select 产品编号,入库单价 from 入库数据 where 入库数量 > 100
15:查询个人护理产品的出库信息
select * from 出库数据 where 产品编号 in (select 产品编号 from 产品信息 where 类别id in (select 类别id from 产品类型 where 产品类别=’个人护理’) )
16:查询出库单价超过10 元的个人护理产品的出库单价和产品说明
select 出库单价,产品说明 from 出库数据,产品信息 where 出库数据.产品编号=产品信息.产品编号 and 出库单价 > 10 and 类别id in (select 类别id from 产品类型 where 产品类别=’个人护理’)
17:嵌套查询家居系列产品的入库信息
select * from 入库数据 where 产品编号 in (select 产品编号 from 产品信息 where 类别id in (select 类别id from 产品类型 where 产品类别=’家居系列’) )
18:查询入库单价比某一 “个人护理”产品入库单价更高的产品入库信息
select * from 入库数据 where 入库单价 > ( select min(入库单价)from 入库数据 where 产品编号 in (select 产品编号 from 产品信息 where 类别id in (select 类别id from 产品类型 where 产品类别=’个人护理’) ) )
19:查询入库单价比任一 “个人护理”产品入库单价更高的产品入库信息
select * from 入库数据 where 入库单价 > ( select max(入库单价)from 入库数据 where 产品编号 in (select 产品编号 from 产品信息 where 类别id in (select 类别id from 产品类型 where 产品类别=’个人护理’) ) )
20:用集合查询方式查询个人护理产品以及入库单价超过20 元的入库产品信息
select * from 入库数据 where 产品编号 in (select 产品编号 from 产品信息 where 类别id in (select 类别id from 产品类型 where 产品类别=’个人护理’) )
union
select * from 入库数据 where 入库单价 > 20
21:用集合查询方式查询个人护理产品且入库单价超过10 元的入库产品信息
select * from 入库数据 where 产品编号 in (select 产品编号 from 产品信息 where 类别id in (select 类别id from 产品类型 where 产品类别=’个人护理’) )
intersect
select * from 入库数据 where 入库单价 > 10
这个intersect数据库access不支持,所以写成
select * from 入库数据 where 入库单价 > 10 and 产品编号 in (select 产品编号 from 产品信息 where 类别id in (select 类别id from 产品类型 where 产品类别=’个人护理’) )
There was a little armpit tightness when I first got it
gay porn Widely Accepted Study Model Round The Globe
cartoon porn10 Tips to Spotting Counterfeit Abercrombie Fitch