Day 18 — Second Highest Salary
100 Days to Amazon
100 Days to Amazon — Day Second Highest Salary
Out of Free Stories? Here is my Friend Link.
Introduction
Hey Guys, Today is Day 18 of the challenge that I took. Wherein I will be solving every day for 100 days the programming questions that have been asked in previous interviews.
Today, We are going to look into an SQL query which had been asked in an Amazon interview.
All these problems are taken from the following e-book. 🎓
This is completely free 🆓 if you have an amazon kindle subscription.
This e-book contains 100 coding problems that have been asked in top tech interview questions. It also has a guide to solving all the problems in 200+ ways. These problems I assure you has been asked in previous interviews.
You have to decide whether you want to go unprepared for a tech interview or go ahead and quick search for this guide to solve the 100 problems.
Begin Your ascent to greatness🚀
Note : this e-book only contains the links to the solutions.
Day 18 — Second Highest Salary🏁
AIM🏹
Write a SQL query to get the second highest salary from the Employee
table.
Example
+----+--------+
| Id | Salary |
+----+--------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
+----+--------+
For example, given the above Employee table, the query should return 200
as the second highest salary. If there is no second highest salary, then the query should return null
.
+---------------------+
| SecondHighestSalary |
+---------------------+
| 200 |
+---------------------+