Blogs Hub

by AskGif | Oct 18, 2020 | Category :coding

Reformat Department Table - Sql - Easy - LeetCode

Reformat Department Table - Sql - Easy - LeetCode

Table: Department +---------------+---------+<br />| Column Name &nbsp; | Type &nbsp; &nbsp;|<br />+---------------+---------+<br />| id &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| int &nbsp; &nbsp; |<br />| revenue &nbsp; &nbsp; &nbsp; | int &nbsp; &nbsp; |<br />| month &nbsp; &nbsp; &nbsp

read more...

by AskGif | Oct 17, 2020 | Category :coding

Swap Salary - Sql - Easy - LeetCode

Swap Salary - Sql - Easy - LeetCode

Given a table salary, such as the one below, that has m=male and f=female values. 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. Note that you must write a single update statement, DO NOT write any sele

read more...

by AskGif | Oct 17, 2020 | Category :coding

Not Boring Movies - Sql - Easy - LeetCode

Not Boring Movies - Sql - Easy - LeetCode

X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies&rsquo; ratings and descriptions.<br />Please write a SQL query to output movies with an odd numbered ID and a description that is not 'boring'. Order the result by rat

read more...

by AskGif | Oct 17, 2020 | Category :coding

Classes More Than 5 Students - Sql - Easy - LeetCode

Classes More Than 5 Students - Sql - Easy - LeetCode

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: +---------+------------+<br />| student | class &nbsp; &nbsp; &nbsp;|<br />+---------+------------+<br />| A &nbsp; &nbsp;

read more...

by AskGif | Oct 17, 2020 | Category :coding

Big Countries - Sql - Easy - LeetCode

Big Countries - Sql - Easy - LeetCode

There is a table World +-----------------+------------+------------+--------------+---------------+<br />| name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| continent &nbsp;| area &nbsp; &nbsp; &nbsp; | population &nbsp; | gdp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<br />+-----------------+----

read more...

by AskGif | Oct 16, 2020 | Category :coding

Rising Temperature - SQL - Easy - LeetCode

Rising Temperature - SQL - Easy - LeetCode

Table: Weather +---------------+---------+<br />| Column Name &nbsp; | Type &nbsp; &nbsp;|<br />+---------------+---------+<br />| id &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| int &nbsp; &nbsp; |<br />| recordDate &nbsp; &nbsp;| date &nbsp; &nbsp;|<br />| temperature &nbsp; | int &nbsp; &

read more...

by AskGif | Oct 16, 2020 | Category :coding

Delete Duplicate Emails - SQL - Easy - LeetCode

Delete Duplicate Emails - SQL - Easy - LeetCode

Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+<br />| Id | Email &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|<br />+----+------------------+<br />| 1 &nbsp;| john@example.com |<br

read more...

by AskGif | Oct 16, 2020 | Category :coding

Customers Who Never Order - Sql - Easy - LeetCode

Customers Who Never Order - Sql - Easy - LeetCode

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. +----+-------+<br />| Id | Name &nbsp;|<br />+----+-------+<br />| 1 &nbsp;| Joe &nbsp; |<br />| 2 &nbsp;| Henry

read more...

by AskGif | Oct 16, 2020 | Category :coding

Employees Earning More Than Their Managers - Sql - Easy - LeetCode

Employees Earning More Than Their Managers - Sql - Easy - LeetCode

The Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id. +----+-------+--------+-----------+<br />| Id | Name &nbsp;| Salary | ManagerId |<br />+----+-------+--------+-----------+<br />| 1 &nbsp;| Joe &nbsp; |

read more...

by AskGif | Oct 16, 2020 | Category :coding

Second Highest Salary - Sql - Easy - LeetCode

Second Highest Salary - Sql - Easy - LeetCode

Write a SQL query to get the second highest salary from the Employee table. +----+--------+<br />| Id | Salary |<br />+----+--------+<br />| 1 &nbsp;| 100 &nbsp; &nbsp;|<br />| 2 &nbsp;| 200 &nbsp; &nbsp;|<br />| 3 &nbsp;| 300 &nbsp; &nbsp;|<br />+----+--------+<br />For example, given the

read more...

by AskGif | Oct 16, 2020 | Category :coding

Combine Two Tables - Sql - Easy - LeetCode

Combine Two Tables - Sql - Easy - LeetCode

Write a SQL query for a report that provides the following information for each person in the Person table, regardless if there is an address for each of those people: Table: Person +-------------+---------+<br />| Column Name | Type &nbsp; &nbsp;|<br />+-------------+---------+<br

read more...