2026/2027 | Complete SQL Command Guide |
Database Applications | Pass Guaranteed - A+ Graded
Section 1: SELECT & Data Retrieval Commands (Q1-15)
Q1. Given the table Employees(EmployeeID INT, FirstName VARCHAR(50),
LastName VARCHAR(50), Salary DECIMAL(10,2)), which query correctly
retrieves the FirstName and LastName columns for all rows?
A. SELECT * FROM Employees WHERE FirstName, LastName
B. SELECT FirstName AND LastName FROM Employees
C. SELECT FirstName, LastName FROM Employees
D. SELECT FirstName + LastName FROM Employees
Correct Answer: C. SELECT FirstName, LastName FROM Employees [CORRECT]
Rationale: The comma-separated column list is the standard syntax for selecting
specific columns. Option A misplaces the columns in a WHERE clause, B uses AND
which is a logical operator, and D attempts concatenation without proper syntax.
Q2. A developer needs to retrieve only the first 10 rows from a table named Orders.
Which syntax is correct for SQL Server?
A. SELECT * FROM Orders LIMIT 10
,B. SELECT TOP 10 * FROM Orders
C. SELECT * FROM Orders WHERE ROWNUM <= 10
D. SELECT FIRST 10 * FROM Orders
Correct Answer: B. SELECT TOP 10 * FROM Orders [CORRECT]
Rationale: SQL Server uses the TOP clause for limiting result sets. Option A is
MySQL/PostgreSQL syntax, C is Oracle syntax, and D is not valid in any major RDBMS.
Q3. Given the table Products(ProductID INT, Category VARCHAR(30),
ProductName VARCHAR(100)) with duplicate category values, which query returns a
list of unique categories?
A. SELECT UNIQUE Category FROM Products
B. SELECT DIFFERENT Category FROM Products
C. SELECT DISTINCT Category FROM Products
D. SELECT Category FROM Products GROUP BY Category
Correct Answer: C. SELECT DISTINCT Category FROM Products [CORRECT]
Rationale: DISTINCT is the ISO SQL standard keyword for eliminating duplicate rows
from the result set. Option D would also work but is unnecessarily complex for simple
deduplication, while A and B use non-standard keywords.
Q4. In the logical processing order of a SQL SELECT statement, which clause is
evaluated immediately after the FROM clause?
,A. SELECT
B. WHERE
C. GROUP BY
D. ORDER BY
Correct Answer: B. WHERE [CORRECT]
Rationale: The standard logical execution order is FROM → WHERE → GROUP BY →
HAVING → SELECT → ORDER BY. The WHERE clause filters rows before any grouping
or selection occurs.
Q5. Given the table Sales(SaleID INT, Amount DECIMAL(10,2), SaleDate
DATE), which query correctly displays the Amount column with the header "Revenue"?
A. SELECT Amount = Revenue FROM Sales
B. SELECT Amount AS Revenue FROM Sales
C. SELECT Revenue AS Amount FROM Sales
D. SELECT ALIAS Amount Revenue FROM Sales
Correct Answer: B. SELECT Amount AS Revenue FROM Sales [CORRECT]
Rationale: The AS keyword is the standard syntax for column aliasing. Option A uses
assignment syntax valid in some contexts but not for display aliases, C reverses the
logic, and D is not valid SQL.
, Q6. Which SELECT statement correctly retrieves all columns and all rows from the
Customers table?
A. SELECT ALL FROM Customers
B. SELECT * FROM Customers
C. SELECT EVERYTHING FROM Customers
D. SELECT COLUMNS(*) FROM Customers
Correct Answer: B. SELECT * FROM Customers [CORRECT]
Rationale: The asterisk (*) is the standard wildcard for selecting all columns in a table.
Options A, C, and D use non-existent SQL keywords.
Q7. A PostgreSQL developer needs to retrieve the first 5 rows from Inventory. Which
syntax is correct for PostgreSQL?
A. SELECT TOP 5 * FROM Inventory
B. SELECT * FROM Inventory LIMIT 5
C. SELECT * FROM Inventory FETCH FIRST 5 ROWS ONLY
D. SELECT * FROM Inventory WHERE ROWNUM <= 5
Correct Answer: B. SELECT * FROM Inventory LIMIT 5 [CORRECT]
Rationale: PostgreSQL supports the LIMIT clause for restricting result sets. Option A is
SQL Server syntax, C is valid in PostgreSQL but less commonly used than LIMIT, and D
is Oracle-specific.