6. Solution of Hacker Rank Employee Salaries.

Author: neptune | 23rd-Jan-2023
🏷️ #SQL #Hackerrank

Employee Salaries

Problem Statement : Write a query that prints a list of employee names (i.e.: the name attribute) for employees in Employee having a salary greater than  per month who have been employees for less than  months. Sort your result by ascending employee_id.

Input Employee table format is described as follows:


where employee_id is an employee's ID number, name is their name, months is the total number of months they've been working for the company, and salary is their monthly salary.




Solution :

For this challenge, we must:

  1. Use an Order By to get Sort your result.

  2. Restrict the selected rows using the WHERE clause so that only records where Salary greater than $2000 and Months greater less than 10 are returned.


Query :

SELECT name FROM Employee

WHERE salary > 2000 AND months < 10

ORDER BY employee_id;


Output:


Hope you learn something !!!

If you have any questions let me know in the comment section.