Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL Sorting and Ordering
00:00
5 left

SQL Sorting and Ordering

EasySQL · PostgreSQL

Problem

How would you write a SQL query to sort an employee table by salary in ascending order?

Use the employees table and return every employee. Salaries that are missing should appear after employees with recorded salaries.

Output

  1. One row per employee with employee_id, employee_name, and salary
  2. Sort by salary ascending, then employee_id ascending for ties

Schema

employees
ColumnTypeDescription
employee_idPKINTUnique employee identifier
employee_nameVARCHAR(100)Employee's full name
salaryNUMERIC(10,2)Annual employee salary
Tablesemployees
Interviewer

Your question is SQL Sorting and Ordering. Start with the requirements and the one table in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.