Pavithra's Space
  • Home
  • Skills
    • SQL
    • HackerRank
      • Revising the Select Query I
      • Revising the Select Query II
      • Select All
      • Select By ID
      • Japanese Cities' Attributes
      • Japanese Cities' Names
      • Weather Observation Station 1
      • Weather Observation Station 3
      • Weather Observation Station 4
      • Weather Observation Station 5
      • Weather Observation Station 6
      • Weather Observation Station 7
      • Weather Observation Station 8
      • Weather Observation Station 9
      • Weather Observation Station 10
      • Weather Observation Station 11
      • Weather Observation Station 12
      • Higher Than 75 Marks
      • Employee Names
      • Employee Salaries
Powered by GitBook
On this page
  1. Skills
  2. HackerRank

Employee Salaries

PreviousEmployee Names

Last updated 1 year ago

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.

Sol:

SELECT name FROM Employee WHERE salary > 2000 AND months < 10 ORDER BY employee_id asc;

Explanation:

  • SELECT name: This part of the query specifies that we want to retrieve the values from the name column of the Employee table.

  • FROM Employee: This specifies the table from which we want to retrieve the data, which is the Employee table.

  • WHERE salary > 2000 AND months < 10: This is a condition added to the query using the WHERE clause. It filters the rows in the Employee table so that only rows where the salary is greater than 2000 and the value in the months column is less than 10 are included in the result.

  • ORDER BY employee_id ASC: This part of the query specifies the order in which the results should be sorted. It orders the results in ascending order based on the values in the employee_id column.

This query retrieves the names of employees from the Employee table where their salary is greater than 2000 and the value in the months column is less than 10. The results are then ordered in ascending order based on the employee_id column.

Employee Salaries | HackerRankHackerRank
Logo