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