sqlbeginner10 minutes

Predict the Output of a Simple SQL SELECT with WHERE Clause

Analyze a basic SQL query that filters data using a WHERE clause and predict what the output will be based on the given data.

Challenge prompt

Given the following table 'Employees' and SQL query, what will be the result of the query? Describe which rows are returned and why. Table: Employees | id | name | department | salary | |----|---------|------------|--------| | 1 | Alice | Sales | 50000 | | 2 | Bob | Marketing | 60000 | | 3 | Charlie | Sales | 70000 | | 4 | David | HR | 45000 | Query: SELECT name, salary FROM Employees WHERE department = 'Sales' AND salary > 55000;

Guidance

  • Look carefully at which conditions the query filters on in the WHERE clause.
  • Identify each row in the table that meets both conditions: department must be 'Sales' and salary must be greater than 55000.

Hints

  • Remember that both conditions in the WHERE clause must be true for a row to be included.
  • Check each employee's department and salary one by one against the filter.

Starter code

SELECT name, salary FROM Employees WHERE department = 'Sales' AND salary > 55000;

Expected output

| name | salary | |---------|--------| | Charlie | 70000 |

Core concepts

SELECT statementWHERE clause filtering

Challenge a Friend

Send this duel to someone else and see if they can solve it.