select*from product where sale_price >500unionselect*from product2 where sale_price >500;
Q2
select*from(select*from product unionselect*from product2)as u
where product_id notin(select product_id from product where product_id notin(select product_id from product2)unionselect product_id from product2 where product_id notin(select product_id from product));
Q3
select sp.shop_id, sp.shop_name, sp.quantity,
p.product_id, p.product_name, p.product_type, p.sale_price,
mp.maxp as'该类商品的最大售价'from product as p
innerjoin shopproduct as sp
on sp.product_id = p.product_id
innerjoin(select product_type,max(sale_price)as maxp from product
groupby product_type
)as mp
on mp.product_type = p.product_type and p.sale_price = mp.maxp;
Q4
select p.product_id, p.product_name, p.product_type, p.sale_price
from product as p
innerjoin(select product_type,max(sale_price)as maxp from product
groupby product_type
)as mp
on mp.product_type = p.product_type and p.sale_price = mp.maxp;
Q5
select p.product_id, p.product_name, p.product_type, p.sale_price,(selectsum(sale_price)from product as p1
where p.sale_price > p1.sale_price
or(p.sale_price = p1.sale_price and p.product_id >= p1.product_id))as'累计求和'from product as p
orderby sale_price;