Published inNothingaholic·Feb 21, 2022Member-onlySQLNotes: Acceptance Rate By DateProblem — What is the overall friend acceptance rate by date? Your output should have the rate of acceptance by the date the request was sent. Order by the earliest date to the latest. Assume that each friend request starts by a user sending (i.e., user_id_sender) a friend request to another user…Sqlnotes3 min readSqlnotes3 min read
Published inNothingaholic·Jan 30, 2022Member-onlySQLNotes: Order DetailsProblem Find order details made by Jill and Eva. Consider the Jill and Eva as first names of customers. Output the order date, details and cost along with the first name. Order records based on the customer id in ascending order. Tables: customers +--------------+---------+ | id…Sqlnotes2 min readSqlnotes2 min read
Published inNothingaholic·Jan 23, 2022Member-onlySQLNotes: Salaries DifferencesProblem Write a query that calculates the difference between the highest salaries found in the marketing and engineering departments. Output just the absolute difference in salaries. Tables: db_employee, db_dept db_employee +--------------+---------+ | id | int | +--------------+---------+ | first_name…Sql2 min readSql2 min read
Published inNothingaholic·Oct 3, 2021Member-onlySQLNotes: Reformat Department Table1179. Reformat Department Table Problem Write an SQL query to reformat the table such that there is a department id column and a revenue column for each month. The query result format is in the following example: Department table: +------+---------+-------+ | id | revenue | month | +------+---------+-------+ | 1…Sql2 min readSql2 min read
Published inNothingaholic·Sep 30, 2021Member-onlySQL Notes: Rank Scores178. Rank Scores Problem Table: Scores +-------------+---------+ | Column Name | Type | +-------------+---------+ | Id | int | | Score | decimal | +-------------+---------+ Id is the primary key for this table. Each row of this table contains the score of a game. …Sql2 min readSql2 min read
Published inNothingaholic·Sep 27, 2021Member-onlySQL Notes: Swap Salary627. Swap Salary Problem Write an SQL query to swap all 'f' and 'm' values (i.e., change all 'f' values to 'm' and vice versa) with a single update statement and no intermediate temp table(s). Note that you must write a single update statement, DO NOT write any select statement for…Sql2 min readSql2 min read
Published inNothingaholic·Sep 26, 2021Member-onlySQL Notes: Delete Duplicate Emails196. Delete Duplicate Emails Problem Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest Id. Return the result table in any order. The query result format is in the following example. Example 1: Input: Person table: +----+------------------+ | Id | Email…Leetcode1 min readLeetcode1 min read
Published inNothingaholic·Sep 26, 2021Member-onlySQL Notes: Nth Highest Salary177. Nth Highest Salary Problem Table: Employee +-------------+------+ | Column Name | Type | +-------------+------+ | Id | int | | Salary | int | +-------------+------+ Id is the primary key column for this table. Each row of this table contains information about the salary of an employee. Write an SQL…Sql2 min readSql2 min read
Published inNothingaholic·Sep 26, 2021Member-onlySQL Notes: Rising Temperature197. Rising Temperature Problem Write an SQL query to find all dates’ Id with higher temperatures compared to its previous dates (yesterday). Return the result table in any order. The query result format is in the following example. Example 1: Input: Weather table: +----+------------+-------------+ | Id | RecordDate | Temperature | +----+------------+-------------+ | 1…Sql1 min readSql1 min read
Published inNothingaholic·Sep 26, 2021Member-onlySQL Notes: Classes More Than 5 Students596. Classes More Than 5 Students Problem There is a table courses with columns: student and class Please list out all classes which have more than or equal to 5 students. For example, the table: +---------+------------+ | student | class | +---------+------------+ | A | Math…Leetcode1 min readLeetcode1 min read