On the journey of
[Leetcode] SQL50 (Recyclable&Low Fat, Customer Referee) 본문
Source: https://leetcode.com/studyplan/top-sql-50/
SQL 50 - Study Plan - LeetCode
Crack SQL Interview in 50 Qs
leetcode.com
: 회원가입 후(진짜 짱 간단하다! 단, 메일인증을 해야 코드 입력이 가능함) SQL 50 스터디플랜 선택하면 시작 가능(?)
크게 SELECT // Basic Joins // Basic Aggregate Functions // Sorting and Grouping // Advanced Select and Joins // Subqueries // Advanced String Functions ,Regex, Clause 카테고리로 나뉘어 있다. .
음 매일같이 풀지는 못하더라도 (그리고 얘보다 급한 게 파이썬이니까^0^....) 열심히...기록해봐야지 :-)
1. https://leetcode.com/problems/recyclable-and-low-fat-products/?envType=study-plan-v2&envId=top-sql-50
Recyclable and Low Fat Products - LeetCode
Can you solve this real interview question? Recyclable and Low Fat Products - Table: Products +-------------+---------+ | Column Name | Type | +-------------+---------+ | product_id | int | | low_fats | enum | | recyclable | enum | +-------------+---------
leetcode.com
Table: Products
Find the ids of products that are both low fat and recyclable.
Return the result table in any order.
The result format is in the following example.
Example 1:
: 사실 영어라 그렇지 any order까지 생각하면, 굳이 정렬 옵션 추가할 거 없이 low_fats 이면서 recyclable 모두 yes(y)인 애를 리턴해라 이거다
# Write your MySQL query statement below
SELECT product_id
FROM Products
WHERE low_fats = 'Y' AND recyclable='Y'
결과는 accepted!
첫 문제였는데 어렵지 않게 풀어내서 기분 좋아짐 헤헤
2. https://leetcode.com/problems/find-customer-referee/?envType=study-plan-v2&envId=top-sql-50
Find Customer Referee - LeetCode
Can you solve this real interview question? Find Customer Referee - Table: Customer +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | name | varchar | | referee_id | int | +-------------+---------+ id is the primary
leetcode.com
Write an SQL query to report the names of the customer that are not referred by the customer with id = 2.
Return the result table in any order.
The query result format is in the following example.
not 조건이 붙었으니까 equation(등호; =) 앞에 ! 를 붙여줌으로써 not을 표현해 줬고, not null 조건(id)을 or로 엮어줬다.
# Write your MySQL query statement below
SELECT name
FROM Customer
WHERE referee_id != 2 OR referee_id is NULL
그리고 역시나 무난히 Accepted :)
solvesql이랑은 제법 다른 것이.... 난이도도 좀더 세분화된 느낌이고, 상위 몇 프로인지도 알려준다,,,
여하간 화이팅!!
'코딩테스트 > SQL' 카테고리의 다른 글
[LeetCode] 595.Big Countries,1068. Product Sales Analysis 1 (0) | 2023.08.27 |
---|---|
[LEETCODE] SQL50 : 595.Big Countries,1148.Article Views 1 (0) | 2023.08.12 |
[SolveSQL] 폐쇄할 따릉이 정류소 찾기 1 (0) | 2023.06.22 |
[SolveSQL] 쇼핑몰의 일일 매출액, 쇼핑몰의 일일 매출액과 ARPPU (0) | 2023.06.21 |
[SolveSQL] 가구 판매의 비중이 높았던 날 찾기,버뮤다 삼각지대에 들어가버린 택배 찾기 (0) | 2023.06.21 |