File tree 11 files changed +69
-39
lines changed
0100-0199/0183.Customers Who Never Order
0584.Find Customer Referee
1700-1799/1757.Recyclable and Low Fat Products
11 files changed +69
-39
lines changed Original file line number Diff line number Diff line change 57
57
### ** SQL**
58
58
59
59
``` sql
60
- select Name as Customers from Customers
61
- where id not in (select CustomerId from Orders)
60
+ select Name as Customers
61
+ from Customers
62
+ where id not in (
63
+ select CustomerId
64
+ from Orders
65
+ );
62
66
```
63
67
64
68
``` sql
65
- # Write your MySQL query statement below
66
69
SELECT
67
- c .Name AS Customers
70
+ c .Name AS Customers
68
71
FROM
69
- customers AS c
70
- LEFT JOIN orders AS o ON c .Id = o .CustomerId
72
+ customers AS c
73
+ LEFT JOIN orders AS o ON c .Id = o .CustomerId
71
74
WHERE
72
- o .CustomerId IS NULL
75
+ o .CustomerId IS NULL ;
73
76
```
74
77
75
78
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -78,19 +78,22 @@ Orders table:
78
78
### ** SQL**
79
79
80
80
``` sql
81
- select Name as Customers from Customers
82
- where id not in (select CustomerId from Orders)
81
+ select Name as Customers
82
+ from Customers
83
+ where id not in (
84
+ select CustomerId
85
+ from Orders
86
+ );
83
87
```
84
88
85
89
``` sql
86
- # Write your MySQL query statement below
87
90
SELECT
88
- c .Name AS Customers
91
+ c .Name AS Customers
89
92
FROM
90
- customers AS c
91
- LEFT JOIN orders AS o ON c .Id = o .CustomerId
93
+ customers AS c
94
+ LEFT JOIN orders AS o ON c .Id = o .CustomerId
92
95
WHERE
93
- o .CustomerId IS NULL
96
+ o .CustomerId IS NULL ;
94
97
```
95
98
96
99
<!-- tabs:end -->
Original file line number Diff line number Diff line change 1
- select Name as Customers from Customers
2
- where id not in (select CustomerId from Orders)
1
+ select Name as Customers
2
+ from Customers
3
+ where id not in (
4
+ select CustomerId
5
+ from Orders
6
+ );
Original file line number Diff line number Diff line change 53
53
referee_id != 2 OR referee_id IS NULL ;
54
54
```
55
55
56
+ MySQL 可使用 ` IFNULL() ` :
57
+
58
+ ``` sql
59
+ SELECT
60
+ name
61
+ FROM
62
+ customer
63
+ WHERE
64
+ IFNULL(referee_id, 0 ) != 2 ;
65
+ ```
66
+
56
67
<!-- tabs:end -->
Original file line number Diff line number Diff line change 68
68
referee_id != 2 OR referee_id IS NULL ;
69
69
```
70
70
71
+ MySQL can use ` IFNULL() ` :
72
+
73
+ ``` sql
74
+ SELECT
75
+ name
76
+ FROM
77
+ customer
78
+ WHERE
79
+ IFNULL(referee_id, 0 ) != 2 ;
80
+ ```
81
+
82
+
71
83
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -76,13 +76,13 @@ World 表:
76
76
77
77
### ** SQL**
78
78
79
- ```
79
+ ``` sql
80
80
SELECT name,
81
- population,
82
- area
83
- FROM World
84
- WHERE area> 3000000
85
- OR population> 25000000
81
+ population,
82
+ area
83
+ FROM world
84
+ WHERE area > 3000000
85
+ OR population > 25000000 ;
86
86
```
87
87
88
88
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -65,13 +65,13 @@ World table:
65
65
66
66
### ** SQL**
67
67
68
- ```
68
+ ``` sql
69
69
SELECT name,
70
- population,
71
- area
72
- FROM World
73
- WHERE area> 3000000
74
- OR population> 25000000
70
+ population,
71
+ area
72
+ FROM world
73
+ WHERE area > 3000000
74
+ OR population > 25000000 ;
75
75
```
76
76
77
77
<!-- tabs:end -->
Original file line number Diff line number Diff line change 1
1
SELECT name,
2
- population,
3
- area
4
- FROM World
5
- WHERE area> 3000000
6
- OR population> 25000000
2
+ population,
3
+ area
4
+ FROM world
5
+ WHERE area > 3000000
6
+ OR population > 25000000 ;
Original file line number Diff line number Diff line change @@ -58,14 +58,13 @@ Result 表:
58
58
### ** SQL**
59
59
60
60
``` sql
61
- # Write your MySQL query statement below
62
61
SELECT
63
62
product_id
64
63
FROM
65
64
Products
66
65
WHERE
67
66
low_fats = ' Y'
68
- AND recyclable = ' Y' ;
67
+ AND recyclable = ' Y' ;
69
68
```
70
69
71
70
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -58,14 +58,13 @@ Products table:
58
58
### ** SQL**
59
59
60
60
``` sql
61
- # Write your MySQL query statement below
62
61
SELECT
63
62
product_id
64
63
FROM
65
64
Products
66
65
WHERE
67
66
low_fats = ' Y'
68
- AND recyclable = ' Y' ;
67
+ AND recyclable = ' Y' ;
69
68
```
70
69
71
70
<!-- tabs:end -->
Original file line number Diff line number Diff line change 1
- # Write your MySQL query statement below
2
1
SELECT
3
2
product_id
4
3
FROM
5
4
Products
6
5
WHERE
7
6
low_fats = ' Y'
8
- AND recyclable = ' Y' ;
7
+ AND recyclable = ' Y' ;
You can’t perform that action at this time.
0 commit comments