Skip to content

Commit 736c9eb

Browse files
committed
feat: add sql solution to lc problems: No.1527,1667
- No.1527.Patients With a Condition - No.1667.Fix Names in a Table
1 parent 00a3c7b commit 736c9eb

File tree

6 files changed

+83
-2
lines changed

6 files changed

+83
-2
lines changed

solution/1500-1599/1527.Patients With a Condition/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ Bob 和 George 都患有代码以 DIAB1 开头的疾病。
5959
### **SQL**
6060

6161
```sql
62-
62+
SELECT
63+
patient_id,
64+
patient_name,
65+
conditions
66+
FROM
67+
patients
68+
WHERE
69+
conditions LIKE 'DIAB1%'
70+
OR conditions LIKE '% DIAB1%';
6371
```
6472

6573
<!-- tabs:end -->

solution/1500-1599/1527.Patients With a Condition/README_EN.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ Patients table:
5959
### **SQL**
6060

6161
```sql
62-
62+
SELECT
63+
patient_id,
64+
patient_name,
65+
conditions
66+
FROM
67+
patients
68+
WHERE
69+
conditions LIKE 'DIAB1%'
70+
OR conditions LIKE '% DIAB1%';
6371
```
6472

6573
<!-- tabs:end -->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SELECT
2+
patient_id,
3+
patient_name,
4+
conditions
5+
FROM
6+
patients
7+
WHERE
8+
conditions LIKE 'DIAB1%'
9+
OR conditions LIKE '% DIAB1%';

solution/1600-1699/1667.Fix Names in a Table/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,31 @@ Result table:
5353

5454
### **SQL**
5555

56+
MySQL
57+
5658
```sql
59+
SELECT
60+
user_id,
61+
CONCAT(UPPER(LEFT(name, 1)), LOWER(SUBSTRING(name, 2))) AS name
62+
FROM
63+
users
64+
ORDER BY
65+
user_id;
66+
```
5767

68+
SQL Server
69+
70+
```sql
71+
SELECT
72+
user_id,
73+
CONCAT(
74+
UPPER(LEFT(name, 1)),
75+
LOWER(SUBSTRING(name, 2, DATALENGTH(name)))
76+
) AS name
77+
FROM
78+
users
79+
ORDER BY
80+
user_id;
5881
```
5982

6083
<!-- tabs:end -->

solution/1600-1699/1667.Fix Names in a Table/README_EN.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,31 @@ Users table:
5252

5353
### **SQL**
5454

55+
MySQL
56+
5557
```sql
58+
SELECT
59+
user_id,
60+
CONCAT(UPPER(LEFT(name, 1)), LOWER(SUBSTRING(name, 2))) AS name
61+
FROM
62+
users
63+
ORDER BY
64+
user_id;
65+
```
5666

67+
SQL Server
68+
69+
```sql
70+
SELECT
71+
user_id,
72+
CONCAT(
73+
UPPER(LEFT(name, 1)),
74+
LOWER(SUBSTRING(name, 2, DATALENGTH(name)))
75+
) AS name
76+
FROM
77+
users
78+
ORDER BY
79+
user_id;
5780
```
5881

5982
<!-- tabs:end -->
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SELECT
2+
user_id,
3+
CONCAT(
4+
UPPER(LEFT(name, 1)),
5+
LOWER(SUBSTRING(name, 2, DATALENGTH(name)))
6+
) AS name
7+
FROM
8+
users
9+
ORDER BY
10+
user_id;

0 commit comments

Comments
 (0)