2021/01(20)
-
[LeetCode MySQL] 180. Consecutive Numbers
180. Consecutive Numbers Table: Logs +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | num | varchar | +-------------+---------+ id is the primary key for this table. Write an SQL query to find all numbers that appear at least three times consecutively. Return the result table in any order. The query result format is in the following example: Logs table: +..
2021.01.19 -
[HackerRank MySQL] Symmetric Pairs
Symmetric Pairs You are given a table, Functions, containing two columns: X and Y. Two pairs (X1, Y1) and (X2, Y2) are said to be symmetric pairs if X1 = Y2 and X2 = Y1. Write a query to output all such symmetric pairs in ascending order by the value of X. List the rows such that X1 ≤ Y1. Sample Input Sample Output 20 20 20 21 22 23 Query select f1.x, f1.y from functions f1 inner join functions ..
2021.01.11 -
[LeetCode MySQL] 181. Employees Earning More Than Their Managers
181. Employees Earning More Than Their Managers The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+ | Id | Name | Salary | ManagerId | +----+-------+--------+-----------+ | 1 | Joe | 70000 | 3 | | 2 | Henry | 80000 | 4 | | 3 | Sam | 60000 | NULL | | 4 | Max | 90000 | NULL | +..
2021.01.11 -
[LeetCode MySQL] 197. Rising Temperature
197. Rising Temperature Table: Weather +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | recordDate | date | | temperature | int | +---------------+---------+ id is the primary key for this table. This table contains information about the temperature in a certain day. Write an SQL query to find all dates' id with higher temperature compared to its prev..
2021.01.11 -
[LeetCode MySQL] 183. Customers Who Never Order
183. Customers Who Never Order Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything. Table: Customers +----+-------+ | Id | Name | +----+-------+ | 1 | Joe | | 2 | Henry | | 3 | Sam | | 4 | Max | +----+-------+ Table: Orders +----+------------+ | Id | CustomerId | +----+------------+ | 1 | 3 | | 2 |..
2021.01.11 -
[LeetCode MySQL] 1179. Reformat Department Table
1179. Reformat Department Table Table: Department +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | revenue | int | | month | varchar | +---------------+---------+ (id, month) is the primary key of this table. The table has information about the revenue of each department per month. The month has values in ["Jan","Feb","Mar","Apr","May","Jun","Jul","Au..
2021.01.11