File tree 7 files changed +106
-2
lines changed
0600-0699/0613.Shortest Distance in a Line
1500-1599/1587.Bank Account Summary II
1700-1799/1795.Rearrange Products Table
7 files changed +106
-2
lines changed Original file line number Diff line number Diff line change 51
51
### ** SQL**
52
52
53
53
``` sql
54
-
54
+ # Write your MySQL query statement below
55
+ select
56
+ min (abs(p1 .x - p2 .x )) as shortest
57
+ from
58
+ Point p1
59
+ join Point p2 on p1 .x != p2 .x ;
55
60
```
56
61
57
62
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -54,7 +54,12 @@ Point table:
54
54
### ** SQL**
55
55
56
56
``` sql
57
-
57
+ # Write your MySQL query statement below
58
+ select
59
+ min (abs(p1 .x - p2 .x )) as shortest
60
+ from
61
+ Point p1
62
+ join Point p2 on p1 .x != p2 .x ;
58
63
```
59
64
60
65
<!-- tabs:end -->
Original file line number Diff line number Diff line change
1
+ # Write your MySQL query statement below
2
+ select
3
+ min (abs(p1 .x - p2 .x )) as shortest
4
+ from
5
+ Point p1
6
+ join Point p2 on p1 .x != p2 .x ;
Original file line number Diff line number Diff line change @@ -102,4 +102,18 @@ HAVING
102
102
SUM (t .amount ) > 10000 ;
103
103
```
104
104
105
+ ``` sql
106
+ # Write your MySQL query statement below
107
+ select
108
+ name,
109
+ sum (amount) as balance
110
+ from
111
+ Users u
112
+ left join Transactions t on u .account = t .account
113
+ group by
114
+ u .account
115
+ having
116
+ sum (amount) > 10000
117
+ ```
118
+
105
119
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -101,4 +101,18 @@ HAVING
101
101
SUM (t .amount ) > 10000 ;
102
102
```
103
103
104
+ ``` sql
105
+ # Write your MySQL query statement below
106
+ select
107
+ name,
108
+ sum (amount) as balance
109
+ from
110
+ Users u
111
+ left join Transactions t on u .account = t .account
112
+ group by
113
+ u .account
114
+ having
115
+ sum (amount) > 10000
116
+ ```
117
+
104
118
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -87,4 +87,34 @@ FROM products
87
87
WHERE store3 IS NOT NULL ;
88
88
```
89
89
90
+ ``` sql
91
+ # Write your MySQL query statement below
92
+ select
93
+ product_id,
94
+ ' store1' as store,
95
+ store1 as price
96
+ from
97
+ Products
98
+ where
99
+ store1 > 0
100
+ union
101
+ select
102
+ product_id,
103
+ ' store2' as store,
104
+ store2 as price
105
+ from
106
+ Products
107
+ where
108
+ store2 > 0
109
+ union
110
+ select
111
+ product_id,
112
+ ' store3' as store,
113
+ store3 as price
114
+ from
115
+ Products
116
+ where
117
+ store3 > 0
118
+ ```
119
+
90
120
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -81,4 +81,34 @@ FROM products
81
81
WHERE store3 IS NOT NULL ;
82
82
```
83
83
84
+ ``` sql
85
+ # Write your MySQL query statement below
86
+ select
87
+ product_id,
88
+ ' store1' as store,
89
+ store1 as price
90
+ from
91
+ Products
92
+ where
93
+ store1 > 0
94
+ union
95
+ select
96
+ product_id,
97
+ ' store2' as store,
98
+ store2 as price
99
+ from
100
+ Products
101
+ where
102
+ store2 > 0
103
+ union
104
+ select
105
+ product_id,
106
+ ' store3' as store,
107
+ store3 as price
108
+ from
109
+ Products
110
+ where
111
+ store3 > 0
112
+ ```
113
+
84
114
<!-- tabs:end -->
You can’t perform that action at this time.
0 commit comments