Im between cherry

Leet Code | MySQL | 627. Swap Salary 본문

데이터분석/practice_query

Leet Code | MySQL | 627. Swap Salary

meal 2020. 8. 30. 14:17

627. Swap Salary

 

https://leetcode.com/problems/swap-salary/

 

Swap Salary - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

Given a table salary, such as the one below, that has m=male and f=female values. 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 temp table.

Note that you must write a single update statement, DO NOT write any select statement for this problem.

After running your update statement, the above salary table should have the following rows:

UPDATE salary
SET sex = CASE 
			WHEN sex = 'f' THEN 'm'
		ELSE 'f' 
	END
Comments