627. Swap Salary
문제
Write an SQL query 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.
Note that you must write a single update statement, do not write any select statement for this problem.
풀이
UPDATE salary SET sex = IF(sex = 'f', 'm','f')
+) 다른 풀이
UPDATE salary
SET sex = CASE WHEN sex = 'f' THEN 'm' ELSE 'f' END
'SQL > LeetCode' 카테고리의 다른 글
| [SQL] LeetCode: 184. Department Highest Salary (0) | 2023.06.08 |
|---|---|
| [SQL] LeetCode: 196. Delete Duplicate Emails (0) | 2023.06.08 |
| [SQL] LeetCode: SELF JOIN 문제 (0) | 2023.05.31 |
| [SQL] LeetCode : LEFT JOIN 문제 (0) | 2023.05.31 |
| [SQL] LeetCode : 1193. Monthly Transactions I (0) | 2023.05.31 |