1811. Find Interview Candidates
https://leetcode.com/problems/find-interview-candidates
Description
Table: Contests
+--------------+------+
| Column Name | Type |
+--------------+------+
| contest\_id | int |
| gold\_medal | int |
| silver\_medal | int |
| bronze\_medal | int |
+--------------+------+
contest\_id is the primary key for this table.
This table contains the LeetCode contest ID and the user IDs of the gold, silver, and bronze medalists.
It is guaranteed that any consecutive contests have consecutive IDs and that no ID is skipped.Table: Users
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| user\_id | int |
| mail | varchar |
| name | varchar |
+-------------+---------+
user\_id is the primary key for this table.
This table contains information about the users.Write an SQL query to report the name and the mail of all interview candidates. A user is an interview candidate if at least one of these two conditions is true:
The user won any medal in three or more consecutive contests.
The user won the gold medal in three or more different contests (not necessarily consecutive).
Return the result table in any order.
The query result format is in the following example:
Follow up:
What if the first condition changed to be "any medal in
nor more consecutive contests"? How would you change your solution to get the interview candidates? Imagine thatnis the parameter of a stored procedure.Some users may not participate in every contest but still perform well in the ones they do. How would you change your solution to only consider contests where the user was a participant? Suppose the registered users for each contest are given in another table.
ac
Last updated
Was this helpful?