1
0
mirror of https://github.com/Snailclimb/JavaGuide synced 2025-06-16 18:10:13 +08:00

Update sql-questions-01.md

This commit is contained in:
paigeman 2023-07-09 10:20:20 +08:00 committed by GitHub
parent 2846e85461
commit fd36493784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1337,7 +1337,7 @@ ORDER BY c.cust_name,o.order_num
这是错误的!只对 `cust_name` 进行聚类确实符合题意,但是不符合 `GROUP BY` 的语法。 这是错误的!只对 `cust_name` 进行聚类确实符合题意,但是不符合 `GROUP BY` 的语法。
select 语句中,如果没有 `GROUP BY` 语句,那么 `cust_name``order_num` 会返回若干个值,而 `sum(quantity _ item_price)` 只返回一个值,通过 `group by` `cust_name` 可以让 `cust_name``sum(quantity _ item_price)` 一一对应起来,或者说**聚类**,所以同样的,也要对 `order_num` 进行聚类。 select 语句中,如果没有 `GROUP BY` 语句,那么 `cust_name``order_num` 会返回若干个值,而 `sum(quantity * item_price)` 只返回一个值,通过 `group by` `cust_name` 可以让 `cust_name``sum(quantity * item_price)` 一一对应起来,或者说**聚类**,所以同样的,也要对 `order_num` 进行聚类。
> **一句话select 中的字段要么都聚类,要么都不聚类** > **一句话select 中的字段要么都聚类,要么都不聚类**