Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL Sorting and Ordering

EasySQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is SQL Sorting and Ordering. Start with the requirements and the one table on the right.

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.

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
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results