当前位置:网站首页>SQL learning group by multi table grouping scenario
SQL learning group by multi table grouping scenario
2022-07-05 09:27:00 【Xu Jiajia 233】
scene
There are currently two tables :
Commodity sales history table 、 Commodity information table
The results that need to be output :
Summary of the quantity of goods currently sold .
Example
CREATE TABLE SellCheck (
goods_id string,
sell_number int
);
INSERT INTO SellCheck VALUES
("111",3),
("222",6),
("111",4),
("111",5),
("222",2);
CREATE TABLE GoodsList (
id string,
name string
);
INSERT INTO GoodsList VALUES
("111","AAA"),
("222","BBB");
select Source code
select GoodsList.name as goods_name,sum(SellCheck.sell_number) as goods_sum
from SellCheck
left outer join GoodsList
on GoodsList.id=SellCheck.goods_id
group by goods_name;
Output results
AAA|12
BBB|8
边栏推荐
- 一次 Keepalived 高可用的事故,让我重学了一遍它
- Figure neural network + comparative learning, where to go next?
- LeetCode 496. 下一个更大元素 I
- nodejs_ 01_ fs. readFile
- 云计算技术热点
- LeetCode 31. 下一个排列
- 阿里云发送短信验证码
- Introduction Guide to stereo vision (6): level constraints and polar correction of fusiello method
- Vs code problem: the length of long lines can be configured through "editor.maxtokenizationlinelength"
- uni-app---uni.navigateTo跳转传参使用
猜你喜欢
LeetCode 31. 下一个排列
Blogger article navigation (classified, real-time update, permanent top)
C语言-从键盘输入数组二维数组a,将a中3×5矩阵中第3列的元素左移到第0列,第3列以后的每列元素行依次左移,原来左边的各列依次绕到右边
Wxml template syntax
Hosting environment API
High performance spark_ Transformation performance
LeetCode 31. Next spread
Introduction Guide to stereo vision (7): stereo matching
Principle and performance analysis of lepton lossless compression
Editor use of VI and VIM
随机推荐
Global configuration tabbar
What is a firewall? Explanation of basic knowledge of firewall
阿里十年测试带你走进APP测试的世界
驾驶证体检医院(114---2 挂对应的医院司机体检)
Uni app implements global variables
项目实战 | Excel导出功能
迁移学习和域自适应
LeetCode 31. Next spread
Applet (global data sharing)
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
A keepalived high availability accident made me learn it again
C language - input array two-dimensional array a from the keyboard, and put 3 in a × 5. The elements in the third column of the matrix are moved to the left to the 0 column, and the element rows in ea
Composition of applet code
2310. 个位数字为 K 的整数之和
Understanding of smt32h7 series DMA and DMAMUX
Principle and performance analysis of lepton lossless compression
Hi Fun Summer, play SQL planner with starrocks!
Kotlin introductory notes (VII) data class and singleton class
VS Code问题:长行的长度可通过 “editor.maxTokenizationLineLength“ 进行配置
高性能Spark_transformation性能