문제
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2F33a00f27-6b9d-4809-ae9c-aa1fcbc04580%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-09-24%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%203.17.12.png)
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2F5e29141f-74a0-4cad-b207-efeacf596bd4%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-09-24%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%203.17.17.png)
풀이
- write an sql query to swap all
f
and m
values with a single update statement and no intermediate emp table(s).
- note that you must write a single update statement, do not write any select statement for this problem.
- the query result format is in the following example.
코드
UPDATE Salary
SET sex = CASE WHEN sex = 'm' THEN 'f' ELSE 'm' END
결과
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2F8b0ad4b1-b252-4cf7-b7cd-200ca67e5a5f%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-09-24%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%203.39.09.png)
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2F65a0a21f-0525-4416-b91d-af1ec9483a63%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-09-24%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%203.39.23.png)
출처 && 깃허브
leetcode
github