1.查询所有speed大于2.8的PC信息
select *
from pcs
where speed > 2.8
2.查询购买model为1007的购买记录信息
select *
from sales
where model = 1007
3.统计2013-12-20购买记录的数量(count)
select count(*)
from sales
where sday=to_date('2013-12-20', 'yyyy-mm-dd')
4.统计2013-12-20购买的总数量(sum)
select sum(quantity)
from sales
where sday = to_date('2013-12-20', 'yyyy-mm-dd')
5.查询硬盘大小出现在两种以上PC电脑上的硬盘大小
select hd
from pcs
group by hd
having count(*) >= 2;
6.查询速度至少3.00以上的PC models信息
select model
from pcs
where speed >= 3.00;
7.查询哪个供应商供应laptops硬盘至少100GB以上的供应商信息
(1)等值连接
select products.*
from products, laptops
where products.model=laptops.model and laptops.hd >= 100;
(2)自然连接(natural join)
select maker, model, ptype
from products natural join laptops
where hd >= 100

这篇博客通过一系列复杂的SQL查询示例,涵盖了Oracle数据库中的等值连接、自然连接、内连接、子查询等多种操作,包括查询特定PC信息、统计购买记录、查找供应商详情以及分析供应商的产品多样性等。实例丰富,适合提升SQL查询技能。
最低0.47元/天 解锁文章
2088

被折叠的 条评论
为什么被折叠?



