当前位置:网站首页>GBase 8s V8.8 SQL 指南:教程-6.1.2(2)
GBase 8s V8.8 SQL 指南:教程-6.1.2(2)
2022-04-22 22:05:00 【GBASE数据库】
下列查询(图 1的修改版本)只返回一行,即表中所有 total_price 值的平均数,如下所示。
图: 查询
SELECT AVG (total_price) average
FROM items
HAVING count(*) > 2;
图: 查询结果
average
$270.97
如果图 3与图 1一样,在 Projection 子句中包含了非聚集列 order_num ,那么必须将
GROUP BY 子句与组列表中的列包含子啊一起。此外,如果不满足 HAVING 子句中的条
件,那么输出将显示列标题以及一条消息指示没有找到任何行。
下列查询包含可以在 GBase 8s 版本的交互 SQL 中使用的所有 SELECT 语句子句(命名
主变量的 INTO 子句只在 SQL API 中可用)。
图: 查询
SELECT o.order_num, SUM (i.total_price) price,
paid_date - order_date span
FROM orders o, items i
WHERE o.order_date > '01/01/98'
AND o.customer_num > 110
AND o.order_num = i.order_num
GROUP BY 1, 3
HAVING COUNT (*) < 5
ORDER BY 3
INTO TEMP temptab1;
该查询连接 orders 和 items 表;使用显示标号、表列名和用作列指示符的整数;对数据进行
分组和排序;并将结果放置在临时表中,如下所示。
版权声明
本文为[GBASE数据库]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_47390342/article/details/124351694
边栏推荐
- How to use lightly to teach programming classes gracefully?
- 7. Comparable to JMeter Net pressure measurement tool - crank Summary - what does crank bring
- Why is bi so important to enterprises?
- 100 billion level im independent development guide! Global instant messaging full set of codes 4 hours quick (II)
- TS classic type gymnastics: how to turn the joint type into the cross type? We need to know three points: distribution law, inversion position, inversion and covariance
- 对象大小与指针压缩--JVM
- 餐饮行业收银系统源码,C# .NET + MSSQL WPF
- Leetcode 04 Median of Two Sorted Arrays
- Basic practice of C language (001-1)
- 【深入浅出强化学习】1 绪论
猜你喜欢
随机推荐
Resource packaging dependency tree
Leetcode 04 Median of Two Sorted Arrays
外部中断---------stm32f407zet6
High end beer is losing young people
MetaWork:拜托,这样远程结对编程超酷的!
What is the working nature of Italian ATOS solenoid valve?
Kunlundb's support for MySQL private DML syntax
Tcp/ip protocol and network layered model
01 背包问题
优麒麟 22.04 LTS 版本正式发布 | UKUI 3.1开启全新体验!
多层感知机的从零开始实现( 从D2L 包中抽取函数)
都是做全屋智能的,Aqara和HomeKit到底有什么不同?
Want to day browser: recommend several easy-to-use desktop browsers
0-1背包问题讲解 & leetcode相关题目总结
【深入浅出强化学习】1 绪论
Youqilin 22.04 lts version is officially released | ukui 3.1 opens a new experience!
Hydraulic shock analysis of haWe haWe hydraulic pump station
Why do others earn more than 10000 yuan a month as we media? How many cents do you have every day? What are the ways of realization?
hawe哈威液压泵站的液压冲击分析
Common commands of Linux









