当前位置:网站首页>Gbase8s database select has order by Clause 3
Gbase8s database select has order by Clause 3
2022-06-29 12:18:00 【Like to eat radish ice cold】
Press CASE Expression sort
ORDER BY Clauses can include CASE Expression to specify the sort key .
In the following example , surface tab_case The column of a_col by INT type . Counter table tab_case Queries for include Projection
Columns in the list a_col And aggregate expressions SUM(a_col), And pass a_col Group the results by the value of .ORDER BY Clause
Specify two sort keys :
Keep up with the ORDER BY After the keyword CASE expression
• AVG(a_col) Aggregate expression :
CREATE TABLE tab_case(a_col INT, b_col VARCHAR(32));
SELECT a_col, SUM(a_col)
FROM tab_case
GROUP BY a_col
ORDER BY CASE
WHEN a_col IS NULL
THEN 1
ELSE 0 END ASC,
AVG(a_col);
Here it is ,ASC The keyword explicitly puts CASE The result of the expression is identified as an ascending sort key . By default ,AVG(a_col)
The sort key also specifies ascending sort .
In the following similar example , Based on the same tab_case The query on the table , the second CASE The expression returns or 1 perhaps 0
As returned AVG(a_col) Sort key value of aggregate value .
SELECT a_col, SUM(a_col)
FROM tab_case GROUP BY a_col
ORDER BY CASE
WHEN a_col IS NULL
THEN 1
ELSE 0 END ASC,
AVG(a_col),
CASE
WHEN AVG(a_col) IS NULL
THEN 1
ELSE 0 END;
边栏推荐
猜你喜欢

初次使用 eolink 感受

Wonderful! Miaoying technology fully implements Zadig to help container construction, and fully embraces kubernetes and Yunyuan

杰理之关于开机发起回连对耳的位置:【篇】

MATLAB Gui 实现点击按钮,打开文件对话框,导入图片功能

谷粒商城项目

Unified exception reporting practice based on bytecode

RepOptimizer: 其实是RepVGG2

ArtBench:第一个类平衡的、高质量的、干净注释的和标准化的艺术品生成数据集

嵌入式数据库开发编程(四)——DDL、DML
Some printer driver PPD files of Lenovo Lingxiang lenovoimage
随机推荐
Jerry's about TWS pairing mode configuration [chapter]
ERP preparation of BOM basis
ERP编制物料清单 基础
GBase8s数据库select有ORDER BY 子句1
Serving millions of developers, the first techo day Tencent technology open day released 7 "lightweight" products
cmake 报错
How to view saved passwords of websites
什么是外链和内链?
&4 express框架
GBase8s数据库INTO STANDARD 和 INTO RAW 子句
杰理之关于 TWS 配对方式配置【篇】
Is it safe for Hengtai securities to open an account? Ranking of securities
GBase8s数据库select有ORDER BY 子句2
Jericho's position on initiating the connection back to the opposite ear: 【 chapter 】
《自卑与超越》生活对你应有的意义
MIT线性代数中文笔记
GBase8s数据库select有ORDER BY 子句6
GBase8s数据库INTO TEMP 子句创建临时表来保存查询结果。
How do I open an account now? Is there a faster and safer opening channel
爱可可AI前沿推介(6.29)