当前位置:网站首页>Gbase8s database select clause 5
Gbase8s database select clause 5
2022-06-09 20:56:00 【Like to eat radish ice cold】
ALL、ANY、SOME Subquery
The following example returns the order number for all orders that contain an item , The total price of this item is greater than the order number 1023 Total for each item in
price . first SELECT Use ALL Subquery , the second SELECT By using MAX The aggregate function produces the same
result .
SELECT DISTINCT order_num FROM items
WHERE total_price > ALL (SELECT total_price FROM items
WHERE order_num = 1023);
SELECT DISTINCT order_num FROM items
WHERE total_price > SELECT MAX(total_price) FROM items
WHERE order_num = 1023);
The following SELECT Statement returns the order number of all orders containing one item , The total price of this item is greater than the order number 1023 in
Total price of at least one item . first SELECT Statements use ANY keyword , And the second one. SELECT Statements use MIN
Aggregation function :
SELECT DISTINCT order_num FROM items
WHERE total_price > ANY (SELECT total_price FROM items
WHERE order_num = 1023);
SELECT DISTINCT order_num FROM items
WHERE total_price > (SELECT MIN(total_price) FROM items
WHERE order_num = 1023);
If the subquery returns exactly one value , You can omit the keyword in the subquery ANY、ALL or SOME. If you omit
ANY、ALL or SOME, And the subquery returns multiple values , You will receive an error . The subquery in the next example returns only one
That's ok , Because it uses aggregate functions :
SELECT order_num FROM items
WHERE stock_num = 9 AND quantity =
(SELECT MAX(quantity) FROM items WHERE stock_num = 9);
See also ALL、ANY and SOME Subquery .
边栏推荐
猜你喜欢

Ceisum三维场景demo

『踩坑记录』IDEA导航栏工具栏添加“后退”功能按钮

排序-快速排序

BI 如何让SaaS产品具有 “安全感”和“敏锐感”(上)

源代码数据防泄露解决方案分析

es自动停止
![[operation and maintenance department] ad domain file permission management](/img/f4/5598384b352b2335145ffa58437439.png)
[operation and maintenance department] ad domain file permission management
![[database data recovery] SQL Server database data recovery case](/img/82/99d3135b6f412a532444e80c2d7faa.jpg)
[database data recovery] SQL Server database data recovery case

CVPR2022 Oral | 用于实时地图视图语义分割的跨视图Transformer

How Bi makes SaaS products have a "sense of security" and "sensitivity" (Part I)
随机推荐
Huawei's cloud industrial intelligence hub provides new momentum for accelerating the upgrading of industrial intelligence
部署 Kubernetes + KubeVirt 以及 KubeVirt的基本使用
[database data recovery] SQL Server database data recovery case
GBase8s数据库select子句5
Who says redis can't save big keys
charles抓包-iphone
GBase8s数据库select子句3
Perfect number (arithmetic borrow problem)
The browser cannot open Baidu, and others can be opened normally
go安装图文教程
Mysql异常:The server time zone value‘XXX'解决
C#中委托与事件之间的一些应用
完美数(算数借位问题)
C#Random的作用
瀏覽器無法打開百度,別的可以正常打開
『踩坑记录』IDEA导航栏工具栏添加“后退”功能按钮
Role of C random
minikube config set driver kvm2
Initial experience of transformation of vite lerna monorepo project
KubeVirt CICD Tekton (2) - task run:datavolume & ssh-key