Questions: SQL: SELECT Statement and Basic Queries
3 questions to test your understanding
Score: 0 / 3
Question 1 Multiple Choice
A table 'employees' has columns: id, name, salary, department. Which query returns only the name and salary columns for every row?
ASELECT * FROM employees
BSELECT name, salary FROM employees
CSELECT employees WHERE columns = name, salary
DGET name, salary FROM employees
SELECT name, salary FROM employees performs projection — it restricts which columns are returned while keeping all rows. SELECT * returns all columns. The other two options are not valid SQL syntax.
Question 2 True / False
Without an ORDER BY clause, a SQL SELECT query guarantees that results are returned in the order the rows were inserted into the table.
TTrue
FFalse
Answer: False
SQL makes no guarantee about row order unless ORDER BY is specified. A database engine is free to return rows in any order that is efficient (e.g., based on index scans or storage layout). Relying on insertion order without ORDER BY is a common mistake that produces unreliable results.
Question 3 Short Answer
In relational algebra terms, what two operations does a basic SELECT ... FROM ... query perform, and how do they map to parts of the SQL syntax?
Think about your answer, then reveal below.
Model answer: Projection (restricting columns) maps to the column list after SELECT; selection (restricting rows) maps to conditions in the WHERE clause. A query with no WHERE clause performs only projection.
This distinction comes directly from relational algebra: projection keeps certain attributes (columns) while selection keeps certain tuples (rows) matching a predicate. Understanding this mapping makes it easier to reason about what a query will return.