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:
parent
2846e85461
commit
fd36493784
@ -1337,7 +1337,7 @@ ORDER BY c.cust_name,o.order_num
|
||||
|
||||
这是错误的!只对 `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 中的字段要么都聚类,要么都不聚类**
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user