当前位置:网站首页>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;
边栏推荐
- 联想领像 lenovoimage 部分打印机 驱动 PPD 文件
- 杰理之关于 TWS 配对方式配置【篇】
- torch.load加载模型报错:Can‘t get attribute ‘vae_vc‘ on <module ‘__main__‘ from ‘xxxx()运行文件路径‘
- TTChat x Zadig 开源共创 Helm 接入场景,环境治理搞得定!
- RSLO:自监督激光雷达里程计(实时+高精度,ICRA2022)
- 保障饮用水安全!番禺沙湾水道水质在线监测系统通过验收
- 杰理之关于 TWS 声道配置【篇】
- ERP编制物料清单 金蝶
- Do you think people who learn machinery are terrible?
- 力扣每日一题-第31天-13.罗马数组转整数
猜你喜欢

The blackened honeysnow ice city wants to grasp the hearts of consumers by marketing?

Win11 web version

基于字节码的统一异常上报实践

镜像漏洞扫描工具:Trivy

AUTOCAD——文字显示方式、CAD怎么直接打开天正图纸

每周推荐短视频:爱因斯坦是怎样思考问题的?
![[VTK] MFC grid editor based on vtk8.2](/img/c5/d0f070ccb819fc682855319b7415e0.png)
[VTK] MFC grid editor based on vtk8.2

Pytoch - distributed communication primitive (with source code)

ERP Kingdee for preparing BOM

当技术人成长为 CEO,应该修改哪些“Bug”?
随机推荐
求大数的阶乘 ← C语言
& 3 view request message and response message in browser
AUTOCAD——文字显示方式、CAD怎么直接打开天正图纸
服务数百万开发者,首届 Techo Day 腾讯技术开放日发布 7 款“轻量级”产品
& 4 express framework
智能垃圾桶(四)——树莓派pico实现超声波测距(HC-SR04)
ERP preparation of BOM basis
Helping the ultimate experience, best practice of volcano engine edge computing
妙!妙盈科技全面实施 Zadig 助力容器化建设,全面拥抱 Kubernetes 和云原生
对p值的理解
Codeforces Round #803 (Div. 2)
《自卑与超越》生活对你应有的意义
MATLAB Gui 实现点击按钮,打开文件对话框,导入图片功能
GBase8s数据库INTO STANDARD 和 INTO RAW 子句
Jerry's WiFi interferes with Bluetooth [chapter]
iMile 利用 Zadig 多云环境周部署千次,跨云跨地域持续交付全球业务
2022 Guangxi provincial safety officer C certificate examination questions and mock examination
MIT线性代数中文笔记
When a technician becomes a CEO, what "bugs" should be modified?
Li Kou daily question - day 31 -13 Maximum perimeter of triangle