본문 바로가기

SQL101

hackerrank Occupations https://www.hackerrank.com/challenges/occupations/problem?isFullScreen=true Occupations | HackerRank Pivot the Occupation column so the Name of each person in OCCUPATIONS is displayed underneath their respective Occupation. www.hackerrank.com 1 2 3 4 5 6 7 8 9 10 select min(case when occupation = 'Doctor' then name end) 'Doctor', min(case when occupation = 'Professor' then name end) 'Professor',.. 2022. 11. 13.
leetcode 1050. Actors and Directors Who Cooperated At Least Three Times 1 2 3 4 5 # Write your MySQL query statement below select actor_id, director_id from ActorDirector group by actor_id, director_id having count(actor_id)>=3 cs 2022. 7. 26.
leetcode 1084. Sales Analysis III 1 2 3 4 5 6 7 8 # Write your MySQL query statement below select p.product_id, p.product_name from Sales s left join Product p on p.product_id = s.product_id group by s.product_id having min(s.sale_date)>='2019-01-01' and max(s.sale_date) 2022. 7. 18.
leetcode 607. Sales Person 1 2 3 4 5 6 7 8 9 10 # Write your MySQL query statement below select s.name from SalesPerson s where s.name not in ( select s.name from orders o left join company c on o.com_id=c.com_id left join SalesPerson s on o.sales_id =s.sales_id where c.name ='RED' ) Colored by Color Scripter cs 2022. 7. 18.
leetcode 1527. Patients With a Condition 1 2 3 4 5 6 # Write your MySQL query statement below select patient_id, patient_name, conditions from Patients where conditions like 'DIAB1%' or conditions like '% DIAB1%' cs 2022. 7. 18.
leetcode 1729. Find Followers Count 1 2 3 4 5 # Write your MySQL query statement below select user_id, count(follower_id) as followers_count from Followers group by user_id order by user_id Colored by Color Scripter cs 2022. 7. 18.
leetcode 1141. User Activity for the Past 30 Days I 1 2 3 4 5 # Write your MySQL query statement below SELECT activity_date AS day, COUNT(DISTINCT user_id) AS active_users FROM Activity WHERE DATEDIFF("2019-07-27", activity_date) 2022. 4. 2.
leetcode 178. Rank Scores 1 2 3 4 5 /* Write your PL/SQL query statement below */ SELECT score , DENSE_RANK() OVER (ORDER BY score DESC ) as rank FROM Scores; Colored by Color Scripter cs 이게 리트코드 Mysql은 구버전이라 그런지 rank() 함수가 없어서 오라클로 돌림. 최신버전 Mysql 도 Rank 함수 있습니다~~ 2022. 4. 2.
leetcode 1158. Market Analysis I 1 2 3 4 5 6 7 8 # Write your MySQL query statement below select user_id as buyer_id, join_date, sum(case when order_id is not null then 1 else 0 end) as orders_in_2019 from users left join orders on users.user_id = orders.buyer_id and year(order_date) = 2019 group by user_id order by buyer_id Colored by Color Scripter cs 2022. 4. 1.
leetcode 586. Customer Placing the Largest Number of Orders 1 2 3 4 5 6 # Write your MySQL query statement below select customer_number from Orders group by customer_number order by count(customer_number) desc limit 1 Colored by Color Scripter cs 2022. 4. 1.
leetcode 584. Find Customer Referee 1 2 3 4 # Write your MySQL query statement below select name from Customer where referee_id!='2' or referee_id is null cs 2022. 4. 1.
leetcode 1148. Article Views I 1 2 3 4 5 # Write your MySQL query statement below select distinct author_id as id from views where author_id=viewer_id order by 1 cs 2022. 3. 31.