[leetcode][Database][Hard] 615. Average Salary: Departments VS Company

題目 Table: Salary +-------------+------+ | Column Name | Type | +-------------+------+ | id | int | | employee_id | int | | amount | int | | pay_date | date | +-------------+------+ id is the primary key column for this table. Each row of this table indicates the salary of an employee in one month. employee_id is a foreign key from the Employee table. Table: Employee +---------------+------+ | Column...

<span title='2022-12-06 14:33:17.216 +0000 UTC'>December 6, 2022</span>&nbsp;·&nbsp;2 分鐘&nbsp;·&nbsp;671 字&nbsp;·&nbsp;ZhengWei, Liu

[leetcode][Database][Hard] 618. Students Report By Geography

題目 Table: Student +-------------+---------+ | Column Name | Type | +-------------+---------+ | name | varchar | | continent | varchar | +-------------+---------+ There is no primary key for this table. It may contain duplicate rows. Each row of this table indicates the name of a student and the continent they came from. A school has students from Asia, Europe, and America. Write an SQL query to pivot the continent...

<span title='2022-12-06 14:08:14.796 +0000 UTC'>December 6, 2022</span>&nbsp;·&nbsp;1 分鐘&nbsp;·&nbsp;449 字&nbsp;·&nbsp;ZhengWei, Liu

[leetcode][Database][Hard] 1097. Game Play Analysis V

題目 Table: Activity +--------------+---------+ | Column Name | Type | +--------------+---------+ | player_id | int | | device_id | int | | event_date | date | | games_played | int | +--------------+---------+ (player_id, event_date) is the primary key of this table. This table shows the activity of players of some games. Each row is a record of a player who logged in and played a number of games (possibly...

<span title='2022-12-06 13:48:34.28 +0000 UTC'>December 6, 2022</span>&nbsp;·&nbsp;2 分鐘&nbsp;·&nbsp;570 字&nbsp;·&nbsp;ZhengWei, Liu

[leetcode][Database][Hard] 1127. User Purchase Platform

題目 Table: Spending +-------------+---------+ | Column Name | Type | +-------------+---------+ | user_id | int | | spend_date | date | | platform | enum | | amount | int | +-------------+---------+ The table logs the history of the spending of users that make purchases from an online shopping website that has a desktop and a mobile application. (user_id, spend_date, platform) is the primary key of this table. The...

<span title='2022-12-06 13:21:25.529 +0000 UTC'>December 6, 2022</span>&nbsp;·&nbsp;2 分鐘&nbsp;·&nbsp;867 字&nbsp;·&nbsp;ZhengWei, Liu

[leetcode][Database][Hard] 1159. Market Analysis II

題目 Table: Users +----------------+---------+ | Column Name | Type | +----------------+---------+ | user_id | int | | join_date | date | | favorite_brand | varchar | +----------------+---------+ user_id is the primary key of this table. This table has the info of the users of an online shopping website where users can sell and buy items. Table: Orders +---------------+---------+ | Column Name | Type | +---------------+---------+ | order_id | int...

<span title='2022-12-06 12:27:16.979 +0000 UTC'>December 6, 2022</span>&nbsp;·&nbsp;2 分鐘&nbsp;·&nbsp;815 字&nbsp;·&nbsp;ZhengWei, Liu

[leetcode][Database][Hard] 1194. Tournament Winners

題目 Table: Players +-------------+-------+ | Column Name | Type | +-------------+-------+ | player_id | int | | group_id | int | +-------------+-------+ player_id is the primary key of this table. Each row of this table indicates the group of each player. Table: Matches +---------------+---------+ | Column Name | Type | +---------------+---------+ | match_id | int | | first_player | int | | second_player | int | | first_score |...

<span title='2022-12-06 09:28:54.784 +0000 UTC'>December 6, 2022</span>&nbsp;·&nbsp;2 分鐘&nbsp;·&nbsp;645 字&nbsp;·&nbsp;ZhengWei, Liu

[leetcode][Database][Hard] 1384. Total Sales Amount by Year

題目 Table: Product +---------------+---------+ | Column Name | Type | +---------------+---------+ | product_id | int | | product_name | varchar | +---------------+---------+ product_id is the primary key for this table. product_name is the name of the product. Table: Sales +---------------------+---------+ | Column Name | Type | +---------------------+---------+ | product_id | int | | period_start | date | | period_end | date | | average_daily_sales | int | +---------------------+---------+ product_id...

<span title='2022-12-06 09:05:48.196 +0000 UTC'>December 6, 2022</span>&nbsp;·&nbsp;2 分鐘&nbsp;·&nbsp;576 字&nbsp;·&nbsp;ZhengWei, Liu

[leetcode][Database][Hard] 1479. Sales by Day of the Week

題目 Table: Orders +---------------+---------+ | Column Name | Type | +---------------+---------+ | order_id | int | | customer_id | int | | order_date | date | | item_id | varchar | | quantity | int | +---------------+---------+ (ordered_id, item_id) is the primary key for this table. This table contains information on the orders placed. order_date is the date item_id was ordered by the customer with id customer_id. Table: Items...

<span title='2022-12-06 08:37:04.705 +0000 UTC'>December 6, 2022</span>&nbsp;·&nbsp;2 分鐘&nbsp;·&nbsp;903 字&nbsp;·&nbsp;ZhengWei, Liu

[leetcode][Database][Hard]1972. First and Last Call On the Same Day

題目 Table: Calls +--------------+----------+ | Column Name | Type | +--------------+----------+ | caller_id | int | | recipient_id | int | | call_time | datetime | +--------------+----------+ (caller_id, recipient_id, call_time) is the primary key for this table. Each row contains information about the time of a phone call between caller_id and recipient_id. Write an SQL query to report the IDs of the users whose first and last calls on...

<span title='2022-12-06 05:39:34.595 +0000 UTC'>December 6, 2022</span>&nbsp;·&nbsp;1 分鐘&nbsp;·&nbsp;479 字&nbsp;·&nbsp;ZhengWei, Liu

[leetcode][Database][Hard] 2004. The Number of Seniors and Juniors to Join the Company

題目 Table: Candidates +-------------+------+ | Column Name | Type | +-------------+------+ | employee_id | int | | experience | enum | | salary | int | +-------------+------+ employee_id is the primary key column for this table. experience is an enum with one of the values ('Senior', 'Junior'). Each row of this table indicates the id of a candidate, their monthly salary, and their experience. A company wants to hire...

<span title='2022-12-05 09:07:42.185 +0000 UTC'>December 5, 2022</span>&nbsp;·&nbsp;2 分鐘&nbsp;·&nbsp;701 字&nbsp;·&nbsp;ZhengWei, Liu