profile
성장하는 주니어 데이터 분석가(Tableau, SQL and Python)
post-thumbnail

Leetcode SQL Solution Day 10

📧 Duplicate Emails Table: Person Write an SQL query to report all the duplicate emails. **Return the result table in any order. The query result format is in the following example.** Example 1: ✅ 해답 여기서는 * 한 개의 Person 테이블에서 중복된 이메일 값을 반환하면 쿼리를 작성*하면 된다. 뭔가 쉬워보이지만 사실 지금까지 우리는 중복제거한 값을 주로 찾았고 DISTINCT를 이용했다. 하지만 이번에는 카운팅을 중복된 값을 찾은 뒤 그 값을 반환해야하므로 조금 까다로울 수 있다. 이번에도 두 가지의 해답을 소개해보겠다. 하나는 HAVING을 이용하여 조건절을 이용하는 것이고 하나는

2022년 12월 30일
·
0개의 댓글
·
post-thumbnail

Leetcode SQL Solution Day 9

🪙 Capital Gain/Loss Table: Stocks Write an SQL query to report the Capital gain/loss for each stock. The Capital gain/loss of a stock is the total gain or loss after buying and selling the stock one or many times. Return the result table in any order. The query result format is in the following example. Example 1: ✅ 해답 여기서는 ** 말그래도 자본의 유입과 손실을 계산하면 되는데 stock_name으로 GROUP BY하고 operation의 Buy, Sell일 때 유입과 손실을 계산하고 이를 price별로

2022년 12월 25일
·
0개의 댓글
·
post-thumbnail

Leetcode SQL Solution Day 8

💁🏻‍♀️ Customer Placing the Largest Number of Orders Table: Orders Write an SQL query to find the customer_number for the customer who has placed the largest number of orders. The test cases are generated so that exactly one customer will have placed more orders than any other customer. The query result format is in the following example. Example 1: ✅ 해답 여기서는 * 가장 많이 주문한 사람의 customer_number의 값을 불러오는 쿼리를 작성*하면 된다. `

2022년 12월 24일
·
0개의 댓글
·
post-thumbnail

Leetcode SQL Solution Day 7

🧑🏻‍💻 User Activity for the Past 30 Days I Table: Activity Write an SQL query to find the daily active user count for a period of 30 days ending 2019-07-27 inclusively. A user was active on someday if they made at least one activity on that day. Return the result table in any order. The query result format is in the following example. Example 1: ✅ 해답 여기서는 ** 2019년 7월 27일에서 를 뺀 날짜가 30일 미만인 날짜들 중 활동한 의 active_users가 몇명인지 반환하는 쿼리를

2022년 12월 20일
·
0개의 댓글
·
post-thumbnail

Leetcode SQL Solution Day 6

🌡️ Rising Temperature Table: Weather Write an SQL query to find all dates' Id with higher temperatures compared to its previous dates (yesterday). Return the result table in any order. The query result format is in the following example. Example 1: ✅ 해답 여기서는 * 어제와 비교하여 기온이 높은 id를 반환하는 쿼리를 작성*하면 된다. 하지만 문제는 테이블이 하나 밖에 없다는 것이다!! 그렇다면 어제보다 더 높은 기온인지는 어떻게 알 수 있을까? 이 때 을 하면 된다. 은 따로 구문을 칠 필요 없이 절에 한번에 와 같이 적으면 구현된다.

2022년 12월 18일
·
0개의 댓글
·
post-thumbnail

Leetcode SQL Solution Day 5

➕ Combine Two Tables Table: Person Table: Address Write an SQL query to report the first name, last name, city, and state of each person in the Person table. If the address of a personId is not present in the Address table, report null instead. Return the result table in any order. The query result format is in the following example. Example 1: ✅ 해답 여기서는 ** 위의 테이블에서 각각 값을 뽑아내어 재구성** 하는 것이다. 이를 적용하기 위해서는 간단하게 을

2022년 12월 18일
·
0개의 댓글
·
post-thumbnail

Leetcode SQL Solution Day 4

❓Employees With Missing Information Table: Employees Table: Salaries Write an SQL query to report the IDs of all the employees with missing information. The information of an employee is missing if: The employee's name is missing, or The employee's salary is missing. Return the result table ordered by employee_id in ascending order. The query result format is in the following example. Example 1: ✅ 해답 여기서는 employee의 정보가 없는 것을 찾는 것인데 그 중에서도 <

2022년 12월 14일
·
0개의 댓글
·
post-thumbnail

Leetcode SQL Solution Day 3

🛠️ Fix names in Table Table: Users Write an SQL query to fix the names so that only the first character is uppercase and the rest are lowercase. Return the result table ordered by user_id. The query result format is in the following example. Example 1: ✅ 해답 여기서는 ** 값의 첫번째 글자들을 대문자로 바꾸고 나머지는 소문자로 바꾸며 이 값을 순서로 정렬하는 것**이다. 이 문제를 해결하기 위해서는 몇가지 함수가 필요한데 일단 해답을 먼저 보자. 해답을 보니 몇가지가 아닌 것 같긴하지만 자세히 설명해보도록 하겠다. 일단 를 가지고 온다. 2

2022년 12월 10일
·
0개의 댓글
·
post-thumbnail

Leetcode SQL Solution Day 2

🔍 들어가기전에 Leetcode에는 생각보다 당장의 주니어 데이터 분석가들에게 그닥 필요없는 구문을 강제하기도 한다. 특히 Day 2에서는 구문과 구문을 강제하는데 벨로그 포스팅에서는 과감히 빼려고한다. 왜냐하면 저 위 두 구문 중 구문은 더더욱이 쓰면 안되는? 것 중 하나이기 때문이다. 그럼 이번 포스팅에는 Day 2의 첫번째 문제와 그에 관련된 내용만 올려보겠다. 💻 Calculate Special Bonus SQL Schema Table: Employees **Write an SQL query to calculate the bonus of each employee. The bonus of an employee is 100% of their salary if the ID of the employee is an odd number and the employee name does not start with the character `'M

2022년 12월 10일
·
0개의 댓글
·
post-thumbnail

Leetcode SQL Solution Day 1

🧐 들어가기전에... 인턴 생활이 시작되고도 벌써 5일이 지난 지금 아직까지 적응하고있는 중이지만 틈틈히 SQL에 관한 포스팅도 올려보려 한다. 이번 시리즈는 라는 해외의 유명한 문제풀이 사이트로 몇 대기업의 코딩테스트 문제도 여기서 갖고 온다는 얘기가 있다. 그리고 일단 무자본인 우리네들에게 가장 좋은 SQL 친구인 MySQL 쿼리를 공부할 수 있는 좋은 곳이기도 하다. 그러므로 우리는 저 위의 사진에서 SQL I. 만 볼거다 ㅎㅎ (근데 회사에서는 쓴다..! OMG) 일단 Day 1은 4문제가 있는데 앞의 두 문제는 너무 쉬워 뒤의 두 문제만 올려보도록 하겠다. 또한 이제 여기서 주의할 점이 있다. 🚨 주의할 점 맨 처음 나는 Python에서 고전을 면치 못하고 있었기에 Leetcode에서의 문제들을 띠엄띠엄 풀고 있었다. 하지만 제목에서 보다시피 가 붙는 데에는 다 이유가 있는 법! 일단, 하루에 Day가 하나씩 열리

2022년 12월 9일
·
0개의 댓글
·