SQL Cheat Sheet 2026
The 30 highest-yield SQL facts, distilled from real exam questions. Print it, save it as a PDF, or study it here — free, no sign-up.
78 questions
120 min time limit
63.00% to pass
- In SQL Server, how do you get the top 10 percent of rows? → SELECT TOP 10 PERCENT
- Why might a DELETE fail due to a foreign key? → Child rows still reference the row being deleted
- Why will the following SQL query fail? `SELECT ProductName FROM Products WHERE ProductID = (SELECT ProductID FROM OrderDetails WHERE Quantity > 100);` → The subquery returns multiple rows, which cannot be compared using the `=` operator.
- To reuse a filtered subset of orders in two different joins within one query, a CTE helps by: → Defining the subset once and referencing it by name
- What does CUME_DIST() compute? → The cumulative distribution: fraction of rows at or below the current value
- Which SQL command is used to remove all rows but keep the table structure most efficiently? → TRUNCATE
- A subquery that references a column from the outer query is called what? → Correlated subquery
- What is a key benefit of using views to simplify complex joins? → Users query one named object instead of rewriting the join
- How do ROWS and RANGE frame modes differ when there are duplicate ORDER BY values? → ROWS counts physical rows; RANGE groups peers with equal values
- What is the difference between RANK() and DENSE_RANK() output for values 10,10,20? → RANK gives 1,1,3 and DENSE_RANK gives 1,1,2
- Which of the SQL commands below deletes all rows in the SalesData table? → DELETE FROM SalesData
- Which window function returns a value between 0 and 1 representing relative standing? → PERCENT_RANK()
- Why might you use a window function instead of GROUP BY for aggregates? → To keep individual rows while adding aggregate columns
- Which clause forces NULL values to appear first in PostgreSQL? → ORDER BY col NULLS FIRST
- Which clause CANNOT typically contain a subquery in standard SQL? → The keyword list of an INDEX definition
- Without an ORDER BY clause, the order of returned rows is: → Not guaranteed
- What is a filtered index (also called a partial index)? → An index built only on rows that satisfy a specified WHERE condition
- When using EXISTS, what should the subquery's SELECT list typically be? → Irrelevant, often SELECT 1
- What does PERCENT_RANK() return for the very first row of an ordered partition? → 0
- In ACID, what does Durability guarantee? → Committed changes survive system failures
- Which returns rows less than AT LEAST ONE value from the subquery? → < ANY
- Which gets a single random row efficiently in MySQL? → ORDER BY RAND() LIMIT 1
- What is the result type of AVG over an integer column in most databases? → A decimal or floating-point value
- A query needs to select all invoices with an `Amount` between 500 and 1000, inclusive of both values. Which `WHERE` clause correctly represents this condition? → WHERE Amount BETWEEN 500 AND 1000
- Which clause defines a column that automatically gets a value when none is supplied on INSERT? → DEFAULT
- Which command permanently saves a transaction's changes? → COMMIT
- Which statement is used to remove a view from the database? → DROP VIEW
- Why might WHERE bonus > 0 exclude rows where bonus is NULL? → NULL comparisons yield unknown, not true
- To extract data from a database, which SQL statement is used? → SELECT
- Which command adds a new column to an existing table? → ALTER TABLE ... ADD COLUMN
Turn these facts into recall:
What Practice Test Geeks adds beyond an AI chat for SQL
An AI chatbot can quiz you, but it can't reproduce the exam conditions or keep your record. Here you get:
- A timed, full-length SQL mock exam — 78 questions in 120 minutes with a 63% pass mark, modeled on the official exam's question count and time limit, followed by a score report broken down by exam domain.
- A fixed SQL question bank: the same test every attempt, so your score is comparable from one try to the next instead of changing with every regenerated quiz.
- Progress saved on your device: completed tests, scores and missed questions stay in My Progress, so you can retake only what you got wrong.
- SQL flashcards built from the same question bank.
- Free SQL practice tests with the correct answer shown after each question.
Was this helpful?