https://leetcode.com/problems/swap-salary
Salary Table 의 sex column 내용을 조건에 따라 업데이트한다.
case 문을 set 에서도 사용 가능하다는 것을 알 수 있다.
UPDATE salary
SET sex = (
CASE
WHEN sex = 'f' THEN 'm'
WHEN sex = 'm' THEN 'f'
END
)
< English (feedback by ChatGPT) >
Update sex column in salary table according to a condition.
(We update the sex column in the Salary table based on certain conditions.)
We can see case statement is available in set statement.
(This shows that a CASE statement can also be used within a SET clause.)
'Coding Interview' 카테고리의 다른 글
| [leetcode] 1965. Employees With Missing Information (0) | 2025.05.15 |
|---|---|
| [leetcode] 1795. Rearrange Products Table (0) | 2025.05.15 |
| [leetcode] 1378. Replace Employee ID With The Unique Identifier (0) | 2025.05.12 |
| [leetcode] 1795. Rearrange Products Table (0) | 2025.05.10 |
| [leetcode] 1741. Find Total Time Spent by Each Employee (0) | 2025.05.10 |