当前位置:网站首页>Li Kou 10821084 solution_ Question of SQL query type
Li Kou 10821084 solution_ Question of SQL query type
2022-06-10 20:35:00 【Across the mountains and rivers, across the sea】
Their thinking
as Take the alias
join on Table joins
group by grouping
having Conditions
Code
1084. Sales analysis III
# Write your MySQL query statement below
/* Write a SQL Inquire about , The report 2019 Products sold only in the spring of . Only in 2019-01-01 to 2019-03-31( contain ) Goods sold between . With In any order Return result table */
select s.product_id,p.product_name
from sales as s
join product as p
on s.product_id=p.product_id/* Join the two tables */
group by s.product_id
having min(s.sale_date) >= '2019-01-01' and
max(s.sale_date) <= '2019-03-31'
Their thinking
To find the best seller, If there is a similar level , Then we need to find them all .
The corresponding in the table seller Per row price The sum is the sales amount => take seller_id Conduct group by Group summation .
After getting every seller After total sales , In descending order , use limit 1 Take the first place => This will bring about a problem : If there is a tie , Can't take it out , The solution is : First use a subquery to get the best seller Sales volume , Then you can find that the sales amount is equal to this seller that will do .
- Sales analysis I
select seller_id
from sales
group by seller_id
having sum(price)=(select sum(price) as pr
from sales
group by seller_id
order by pr desc
limit 1)
边栏推荐
- How to stack double and float in the bottom layer of C language
- ResourceNotFoundException : Unable to find resource
- 知识图谱/关系可视化
- 软件定义边界(SDP)
- mixin--混入
- Fs4100 lithium battery charging management IC input 12V to 8.4v charging IC
- Microsoft Word 教程,如何在 Word 中更改页面方向、为页面添加边框?
- The most common habits from more than 200 English papers written by gradua
- Redis cluster form - sentry mode cluster and high availability mode cluster - redis learning notes 003
- FS4521恒压线性充电IC
猜你喜欢

测试apk-异常管控netLocation攻击者开发

8.4v双节锂电池专业充电ic(FS4062A)

JD released ted-q, a large-scale and distributed quantum machine learning platform based on tensor network acceleration

Basic instructions for ads and AXD

Tutoriel Microsoft Word "5", comment changer les marges de page et créer une barre de nouvelles en word?

Spark ShuffleManager

HM3416H降压IC芯片PWM/PFM 控制 DC-DC 降压转换器
![[technical fragment] implementation of renaming and filtering duplicate name files with suffixes](/img/be/d33cd20ae37dfb5d3ea59ce8b1e568.png)
[technical fragment] implementation of renaming and filtering duplicate name files with suffixes

监控易打造“准生态”格局,赋能信创“平替”

FPGA state machine
随机推荐
Cloud native community boss blog
中衍期货公司是国内的正规平台吗?开户安全吗?想开个期货账户
【观察】昇腾智行:场景驱动,创新先行,为智慧交通按下“加速键”
Microsoft Word 教程,如何在 Word 中更改页面方向、为页面添加边框?
Jiangbolong forestee xp2000 PCIe 4.0 SSD multi encryption function, locking data security
Does Seata still not support sqlserver?
【legendre】多项式
暗黑破坏神不朽数据库怎么用 暗黑破坏神手游不朽数据库使用方法
Development scheme of 108k humidifier for water replenishment instrument_ Single chip microcomputer_ NY8A051F_ Development of single chip microcomputer
PDU session flow
Fs4521 constant voltage linear charging IC
nodejs: 官方文档3 dgram Stream
[technical fragment] implementation of renaming and filtering duplicate name files with suffixes
seata 还是不支持sqlserver吗?
在阿里云国际上使用 OSS 和 CDN 部署静态网站
NFS network mount to create server image
hidden danger? Limited meaning? Can't stop the real cooking Mini kitchenware hot 618
Solve the problem that the idea automatically becomes * when there are more than 5 identical packages
利用阿里云国际购买的服务器搭建个人网站步骤
vulnhub-The Planets: Earth