Update ch02: 基础查询与排序.md

This commit is contained in:
mba1398
2021-08-13 22:37:33 +08:00
committed by GitHub
parent 9e09095b55
commit d75321c4f5

View File

@@ -163,11 +163,11 @@ OR 相当于“或者”,类似数学中的取并集。
AND运算符工作效果图
![图片](https://github.com/datawhalechina/team-learning-sql/blob/main/img/ch02/ch02.01and.png)
![图片](./img/ch02/ch02.01and.png)
OR运算符工作效果图
![图片](https://github.com/datawhalechina/team-learning-sql/blob/main/img/ch02/ch02.02or.png)
![图片](./img/ch02/ch02.02or.png)
### 通过括号优先处理
@@ -213,11 +213,11 @@ SELECT product_name, product_type, regist_date
真值表
![图片](https://github.com/datawhalechina/team-learning-sql/blob/main/img/ch02/ch02.03true.png)
![图片](./img/ch02/ch02.03true.png)
查询条件为P ANDQ OR R的真值表
![图片](https://github.com/datawhalechina/team-learning-sql/blob/main/img/ch02/ch02.04true2.png)
![图片](./img/ch02/ch02.04true2.png)
### 含有NULL时的真值
@@ -229,7 +229,7 @@ NULL的真值结果既不为真也不为假因为并不知道这样一个
三值逻辑下的AND和OR真值表为
![图片](https://github.com/datawhalechina/team-learning-sql/blob/main/img/ch02/ch02.05true3.png)
![图片](./img/ch02/ch02.05true3.png)
##
## 练习题-第一部分
@@ -355,7 +355,7 @@ SELECT product_type, COUNT(*)
```
按照商品种类对表进行切分
![图片](https://github.com/datawhalechina/team-learning-sql/blob/main/img/ch02/ch02.06cut.png)
![图片](./img/ch02/ch02.06cut.png)
这样GROUP BY 子句就像切蛋糕那样将表进行了分组。在 GROUP BY 子句中指定的列称为**聚合键**或者**分组列**。
@@ -403,7 +403,7 @@ SELECT purchase_price, COUNT(*)
将表使用GROUP BY分组后怎样才能只取出其中两组
![图片](https://github.com/datawhalechina/team-learning-sql/blob/main/img/ch02/ch02.07groupby.png)
![图片](./img/ch02/ch02.07groupby.png)
这里WHERE不可行因为WHERE子句只能指定记录的条件而不能用来指定组的条件例如“数据行数为 2 行”或者“平均值为 500”等
@@ -490,11 +490,11 @@ product_type | sum | sum
| 5000 | 3300
| 600 | 320
```
![图片](https://github.com/datawhalechina/team-learning-sql/blob/main/img/ch02/ch02.08test26.png)
![图片](./img/ch02/ch02.08test26.png)
### 2.7
此前我们曾经使用SELECT语句选取出了product商品表中的全部记录。当时我们使用了 `ORDER BY` 子句来指定排列顺序,但现在已经无法记起当时如何指定的了。请根据下列执行结果,思考 `ORDER BY` 子句的内容。
![图片](https://github.com/datawhalechina/team-learning-sql/blob/main/img/ch02/ch02.09test27.png)
![图片](./img/ch02/ch02.09test27.png)