본문 바로가기

SQL

(22)
(MySQL) - LeetCode (medium) 176. Second Highest Salary https://leetcode.com/problems/second-highest-salary/description/ Second Highest 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 sub query로 해결한 문제였습니다. 📕 풀이방법 📔 풀이과정 가장 간단한 방식으로 중복값 제거후 내림차순으로 정렬해 한 행만 나오도록 limit 1로 설정, 이후 두 번째부터 출력하도록 offset을 1로 설정해 작성했으나 틀렸다고 나옵니다. 행이 한 개..
(MySQL) - LeetCode (easy) 182. Duplicate Emails https://leetcode.com/problems/customers-who-never-order/description/ Customers Who Never Order - 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 left outer join을 사용해 해결했습니다. 📕 풀이방법 📔 풀이과정 Customers table의 기본 key id와 Orders table의 기본 key customerId에 대해 join을 해줍니다. id에 해당하는 customerI..
(MySQL) - LeetCode (easy) 182. Duplicate Emails https://leetcode.com/problems/duplicate-emails/description/ Duplicate Emails - 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 group by를 사용해본 문제였습니다. 📕 풀이방법 📔 풀이과정 집계함수를 쓰기 위해 group by를 사용했습니다. having으로 email에 대한 count가 1초과시 중복되었으므로 해당 email들을 select해줍니다. 📕 Code 📔 MySQL select emai..
(MySQL) - LeetCode (easy) 181. Employees Earning More Than Their Managers https://leetcode.com/problems/employees-earning-more-than-their-managers/description/ Employees Earning More Than Their Managers - 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 inner join을 사용해본 문제였습니다. 📕 풀이방법 Table A, B를 원 형태의 집합으로 표현했을 때 inner join을 하면 칠한 부분처럼 교집합에 해당하는 row들을 얻을..
(MySQL) - LeetCode (easy) 175. Combine Two Tables https://leetcode.com/problems/combine-two-tables/description/ Combine Two Tables - 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 join을 사용해보는 문제였습니다. 📕 풀이방법 left outer join을 사용합니다. A와 B Table을 원 형태의 집합으로 표현했을 때 다음 영역의 data를 뽑아내는 join문입니다. Syntax는 다음과 같습니다. custom가능한 부분 {}로 감싼 부분으로..
(MySQL Workbench) - MySQL version sql로 확인 🍳머리말 workbench mysql version을 알 수 있습니다. 📕SQL로 확인 📔 방법 workbench 상에서 connection이 성공해서 접속한 상태에서 다음 sql문을 입력하면 됩니다. select version();