LeetCode342 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. leetcode 511. Game Play Analysis I 1 2 3 4 # Write your MySQL query statement below select player_id, min(event_date) as first_login from Activity group by player_id cs 2022. 3. 31. leetcode 1965. Employees With Missing Information 1 2 3 4 5 6 7 8 select employee_id from( select employee_id from Employees union all select employee_id from Salaries )t group by employee_id having count(*)=1 order by 1 Colored by Color Scripter cs 2022. 3. 31. leetcode 1179. Reformat Department Table 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 # Write your MySQL query statement below SELECT id, SUM(CASE WHEN month = 'jan' THEN revenue END) AS Jan_Revenue, SUM(CASE WHEN month = 'feb' THEN revenue END) AS Feb_Revenue, SUM(CASE WHEN month = 'mar' THEN revenue END) AS Mar_Revenue, SUM(CASE WHEN month = 'apr' THEN revenue END) AS Apr_Revenue, SUM(CASE WHEN month = 'may' THEN revenue END) AS May_Revenu.. 2022. 3. 31. leetcode 1407. Top Travellers 1 2 3 4 5 6 # Write your MySQL query statement below select u.name, IFNULL(sum(r.distance), 0) as travelled_distance from Users u left join Rides r on u.id=r.user_id group by r.user_id order by 2 desc, 1 asc Colored by Color Scripter cs 2022. 3. 31. leetcode 1890. The Latest Login in 2020 1 2 3 4 5 6 7 # Write your MySQL query statement below select user_id, max(time_stamp) as last_stamp from Logins where 1=1 and time_stamp>='2020-01-01' and time_stamp 2022. 3. 30. leetcode 1484. Group Sold Products By The Date 1 2 3 4 5 6 7 # Write your MySQL query statement below select sell_date, COUNT(DISTINCT product) num_sold, group_concat(DISTINCT product) products from Activities group by sell_date order by sell_date Colored by Color Scripter cs 2022. 3. 30. 이전 1 ··· 16 17 18 19 20 21 22 ··· 29 다음