Skip to content

Commit ba975cb

Browse files
committed
feat: add solutions to lc problems: No.0613,1587,1795
* No.0613.Shortest Distance in a Line * No.1587.Bank Account Summary II * No.1795.Rearrange Products Table
1 parent 9ebcd48 commit ba975cb

File tree

7 files changed

+106
-2
lines changed

7 files changed

+106
-2
lines changed

solution/0600-0699/0613.Shortest Distance in a Line/README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@
5151
### **SQL**
5252

5353
```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;
5560
```
5661

5762
<!-- tabs:end -->

solution/0600-0699/0613.Shortest Distance in a Line/README_EN.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ Point table:
5454
### **SQL**
5555

5656
```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;
5863
```
5964

6065
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
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;

solution/1500-1599/1587.Bank Account Summary II/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,18 @@ HAVING
102102
SUM(t.amount) > 10000;
103103
```
104104

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+
105119
<!-- tabs:end -->

solution/1500-1599/1587.Bank Account Summary II/README_EN.md

+14
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,18 @@ HAVING
101101
SUM(t.amount) > 10000;
102102
```
103103

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+
104118
<!-- tabs:end -->

solution/1700-1799/1795.Rearrange Products Table/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,34 @@ FROM products
8787
WHERE store3 IS NOT NULL;
8888
```
8989

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+
90120
<!-- tabs:end -->

solution/1700-1799/1795.Rearrange Products Table/README_EN.md

+30
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,34 @@ FROM products
8181
WHERE store3 IS NOT NULL;
8282
```
8383

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+
84114
<!-- tabs:end -->

0 commit comments

Comments
 (0)