leetcode(3)
-
[LeetCode] 627. Swap Salary
UPDATE문에 CASE WHEN 사용하기 UPDATE의 기본 구조 1. 조건 없이 모든 컬럼의 값을 변경할때 UPDATE 테이블명 SET 컬럼=값 ; 2. 조건에 맞는 컬럼의 값을 변경할때 UPDATE 테이블명 SET 컬럼=값 WHERE 조건식 ; 나의 작성 코드 UPDATE salary set sex = CASE WHEN MOD(id,2)=0 THEN 'm' WHEN MOD(id,2)!=0 THEN 'f' END ; 인프런 백문이불여일타의 정답 UPDATE salary set sex = CASE WHEN sex='f' THEN 'm' ELSE 'f' END ; 주요 구문 UPDATE 테이블명 SET = CASE WHEN 구문
2022.10.25 -
[LeetCode] 1965. Employees With Missing Information
SELECT employee_id FROM (SELECT e.employee_id FROM employees AS e LEFT JOIN salaries AS s ON e.employee_id = s.employee_id WHERE s.salary IS NULL UNION SELECT s.employee_id FROM employees AS e RIGHT JOIN salaries AS s ON e.employee_id = s.employee_id WHERE e.name IS NULL)sub ORDER BY 1 OUTER JOIN : FULL OUTER JOIN , LEFT OUTER JOIN, RIGHT OUTER JOIN FULL OUTER JOIN = LEFT JOIN UNION RIGHT JOIN U..
2022.06.16 -
[LeetCode] 180. Consecutive Numbers
SELECT id AS ConsecutiveNums FROM ( SELECT id, num, LEAD(num,1) OVER (ORDER BY id) AS two_num, LEAD(num,2) OVER (ORDER BY id) AS three_num FROM Logs) sub WHERE num=two_num AND two_num=three_num
2022.06.09