当前位置:网站首页>第4章 集合运算
第4章 集合运算
2022-07-23 08:35:00 【长沙的沙】
Q1
select * from product where sale_price > 500
union
select * from product2 where sale_price > 500;
Q2
select * from (select * from product union select * from product2) as u
where product_id not in (
select product_id from product where product_id not in (select product_id from product2)
union
select product_id from product2 where product_id not in (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
inner join shopproduct as sp
on sp.product_id = p.product_id
inner join (
select product_type, max(sale_price) as maxp from product
group by 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
inner join (
select product_type, max(sale_price) as maxp from product
group by 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,
(select sum(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
order by sale_price;
边栏推荐
- Offline data interoperability
- The shell needs to know the commands when running
- What level of rtx3070ti graphics card? What level of rtx3070ti graphics card? How about rtx3070ti graphics card
- The difference between rtx3080ti and 3090. Which one is more cost-effective, rtx3080ti or 3090
- Canvas eraser function
- JS to obtain age through ID card
- Consensys Quorum Benchmark Test
- 采样和数据驱动
- 扁平样式反馈表单页面
- Spark统计每天新增用户
猜你喜欢
![[review of analog electricity - diode]](/img/dc/7b3c3187000be24053f0e69733444d.jpg)
[review of analog electricity - diode]

581. 最短无序连续子数组

初识并查集

js纹理样式饼图插件

VK36N5D抗电源干扰/手机干扰 5键5通道触摸检测芯片防呆功能触摸区域积水仍可操作

【模电复习——二极管】

Surrounded Regions

ValidationError: Invalid options object. Dev Server has been initialized using an options object th

How about the nuclear display performance of Ruilong R7 Pro 6850h? What level is it equivalent to

Rtx3080ti and rtx3080 gap 3080 and 3080ti parameter comparison
随机推荐
-bash: ifconfig: command not found
canvas橡皮擦功能
LabVIEW运行中改变Chart的历史长度
寻找峰值[抽象二分练习]
Renforcement de l'apprentissage - points de compréhension du gradient stratégique
Design instantiation and connection
力扣142题:环形链表2
ValidationError: Invalid options object. Dev Server has been initialized using an options object th
手工测试如何转向自动化测试?字节5年自动化经验浅谈一下...
将我理解的web3.0讲给你听
Process blocks and methods
求岛屿最大面积--深度优先搜索(染色法)
How many processors is Tianji 820 equivalent to Xiaolong? How about Tianji 1100 equivalent to Xiaolong? How about Tianji 820
js日历样式饼图统计插件
数据库连接池 & DBUtils
Talent evaluation Core i7 12850hx and i7 12700h which to choose
What level of rtx3070ti graphics card? What level of rtx3070ti graphics card? How about rtx3070ti graphics card
How about the performance of Intel Celeron 7305? What level is it equivalent to
Drag and drop----
Notes on the seventh day