Engineering Team by Salary
Easysql
Write a query that returns the id, name, and salary of every employee in the 'Engineering' department, ordered by salary from highest to lowest.
sqlCREATE TABLE employees ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, department TEXT NOT NULL, salary INTEGER NOT NULL, manager_id INTEGER );
Sample data (this is what your query runs against when you press Run):
sqlINSERT INTO employees (id, name, department, salary, manager_id) VALUES (1, 'Asha', 'Engineering', 85000, NULL), (2, 'Rohan', 'Engineering', 72000, 1), (3, 'Neha', 'Sales', 68000, NULL), (4, 'Vikram', 'Sales', 61000, 3), (5, 'Priya', 'Engineering', 79000, 1), (6, 'Karan', 'Marketing', 55000, NULL), (7, 'Divya', 'Marketing', 58000, 6), (8, 'Aman', 'Sales', 64000, 3);
Example 1
Input
(none)
Output
id name salary 1 Asha 85000 5 Priya 79000 2 Rohan 72000
WHERE department = 'Engineering' filters to the right rows; ORDER BY salary DESC sorts highest-first. Reference: SELECT id, name, salary FROM employees WHERE department = 'Engineering' ORDER BY salary DESC;