Write a query to retrieve employees whose salary is greater than 50,000, sorted by salary in descending order.
1Times asked
Jun 2026Last seen
Jun 2026First seen
💡 Model Answer
To retrieve employees with a salary above 50,000 and order them by salary descending, you can use a simple SELECT statement with a WHERE clause and ORDER BY. For example:
sql
SELECT employee_id,
first_name,
last_name,
salary
FROM employees
WHERE salary > 50000
ORDER BY salary DESC;Explanation:
SELECTlists the columns you want to return.FROM employeesspecifies the table.WHERE salary > 50000filters rows to only those with a salary greater than 50,000.ORDER BY salary DESCsorts the result set from highest to lowest salary.
If you also need to include the employee’s department, you could join the departments table:
sql
SELECT e.employee_id,
e.first_name,
e.last_name,
e.salary,
d.department_name
FROM employees e
JOIN departments d ON e.department_id = d.department_id
WHERE e.salary > 50000
ORDER BY e.salary DESC;This query demonstrates basic filtering, sorting, and joining, which are core skills for any SQL developer.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500