当前位置:网站首页>GBase 8s V8.8 SQL 指南:教程-6.1.1(2)
GBase 8s V8.8 SQL 指南:教程-6.1.1(2)
2022-04-22 05:24:00 【GBASE数据库】
下列查询检索每个订单的商品数和所有商品的总价。
图: 查询
SELECT order_num, COUNT (*) number, SUM (total_price) price
FROM items
GROUP BY order_num;
GROUP BY 子句导致 items 表的行数被收集为组,每个组由具有相同 order_num 值的行组
成(即,将每个订单的商品收集在一起)。在数据库服务器构成组之后,就在每个组中应
用聚集行数 COUNT 和 SUM 。
图 4对每一组返回每一行。它还使用标号来为 COUNT 和 SUM 表达式的结果提供名称,
如下所示。
图: 查询结果
order_num number price
1001 1 $250.00
1002 2 $1200.00
1003 3 $959.00
1004 4 $1416.00
⋮
1021 4 $1614.00
1022 3 $232.00
1023 6 $824.00
该结果将 items 表的行收集到具有相同订单号的组中,并计算每个组中行的 COUNT 和价
格的 SUM。
不能在 GROUP BY 子句中包含 TEXT 、BYTE 、CLOB 或 BLOB 列。要进行分组,必
须能够进行排序,并且这些数据类型不存在自然排序顺序。
与 ORDER BY 子句不同,GROUP BY 子句不对数据进行排序。如果想要按特定顺序对数
据进行排序,或在投影列表中的聚集上排序,那么在 GROUP BY 子句之后包含 ORDER
BY 子句。
版权声明
本文为[GBASE数据库]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_47390342/article/details/124326578
边栏推荐
猜你喜欢

After the MySQL database runs the code, the question mark is displayed in Chinese?

Meetup 02 review: Q & A highlights

Codeforces Round #784 (Div. 4) All Problems

abcabc
![[WPF] use ellipse or rectangle to make circular progress bar](/img/5b/6153e0decf612f2a1c28093d595bb2.png)
[WPF] use ellipse or rectangle to make circular progress bar
My creation anniversary
![[C] file operation](/img/fd/ddf94b0ffa743f2288f723a263a045.png)
[C] file operation

Codeforces Round #784 (Div. 4) All Problems

Domain name encryption is not enough: privacy leakage via IP based website fingerprinting

Four startup modes of activity
随机推荐
Query result processing
Machine learning -- under fitting, over fitting and regularization
abcabc
idea2021. 1. When writing SQL in mapper: unable to resolve column / table
Learning C language diary from scratch -- day27 minesweeping
IO stream
TCP three handshakes and four waves (2022.4.18-4.24)
Auto.js 画布设置防锯齿paint.setAntiAlias(true);
Meetup 02 review: Q & A highlights
Cookie injection
Ezyslice cut characters
Configure security policy on ENSP
Event system for ugui source code analysis in unity (9) - input module (2)
[WPF] making navigation bar with RadioButton
Mengxin sees the recruitment of volunteers in the open source community of wedatasphere
Codeforces Round #784 (Div. 4) All Problems
Detailed explanation of ten functional features of ETL's kettle tool
Sourcetree version backtracking and single change version backtracking
遇见DOM
Basic principle and numerical method of finite element method_ Basic principle of finite element method