龙珠训练营task04

4.1和4.2 product2 未知

4.3
select
product_id,product_name,product_type,sale_p
rice,shop_name

from product as p1 natural join
shop_product as p2

where sale_price in

(
SELECT 
max(sale_price)

from product

group by product_type
)

 

4.4
select *

from product 

where sale_price in
(
SELECT 
max(sale_price)
from product

group by product_type
)

group by product_type

select *

from product as p1 inner join product as p2

on p1.product_id=p2.product_id

where p1.sale_price in (SELECT 

max
(sa

le_price)

from product

group by product_type
)

group by p1.product_type

 

 

4.5
#用关联子查询实现:在product表中,

#取出 product_id, produc_name, slae_price, 
#并按照商品的售价从低到高进行排序、对售价进
行累计求和。


select product_id,product_name,sale_price,
(
select sum(sale_price) 
from product
) as
sum

from product

group by product_id

order by sale_price 


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值