Skip to content

Commit 9f5ac42

Browse files
committed
task: #627
1 parent 5fe3968 commit 9f5ac42

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Have a good contributing!
4848
- [610. Triangle Judgement](./leetcode/easy/610.%20Triangle%20Judgement.sql)
4949
- [619. Biggest Single Number](./leetcode/easy/619.%20Biggest%20Single%20Number.sql)
5050
- [620. Not Boring Movies](./leetcode/easy/620.%20Not%20Boring%20Movies.sql)
51+
- [627. Swap Salary](./leetcode/easy/627.%20Swap%20Salary.sql)
5152
- [1068. Product Sales Analysis I](./leetcode/easy/1068.%20Product%20Sales%20Analysis%20I.sql)
5253
- [1075. Project Employees I](./leetcode/easy/1075.%20Project%20Employees%20I.sql)
5354
- [1327. List the Products Ordered in a Period](./leetcode/easy/1327.%20List%20the%20Products%20Ordered%20in%20a%20Period.sql)

leetcode/easy/627. Swap Salary.sql

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
Question 627. Swap Salary
3+
Link: https://leetcode.com/problems/swap-salary/description/
4+
5+
Table: Salary
6+
7+
+-------------+----------+
8+
| Column Name | Type |
9+
+-------------+----------+
10+
| id | int |
11+
| name | varchar |
12+
| sex | ENUM |
13+
| salary | int |
14+
+-------------+----------+
15+
id is the primary key (column with unique values) for this table.
16+
The sex column is ENUM (category) value of type ('m', 'f').
17+
The table contains information about an employee.
18+
19+
20+
Write a solution to swap all 'f' and 'm' values (i.e., change all 'f' values to 'm' and vice versa) with a single update statement and no intermediate temporary tables.
21+
22+
Note that you must write a single update statement, do not write any select statement for this problem.
23+
*/
24+
25+
UPDATE Salary
26+
SET sex = (CASE
27+
WHEN sex = 'm'
28+
THEN 'f'
29+
ELSE 'm'
30+
END)

0 commit comments

Comments
 (0)