Question bank
Pick an answer to see if you're right — with an explanation.
All topicsPythonSQL / MySQLData ScienceNumPyPandasMatplotlibMachine LearningDeep LearningArtificial IntelligenceLarge Language ModelsDjangoAPIsGit & GitHubPower BIExcelStatistics
SQL / MySQLEasy
Which clause filters groups after aggregation?
aHAVING
bWHERE
cGROUP BY
dORDER BY
Explanation: HAVING filters aggregated groups.
SQL / MySQLEasy
Which keyword starts a Common Table Expression?
aWITH
bUSING
cDEFINE
dAS
Explanation: A CTE is introduced with `WITH name AS (...)`.
SQL / MySQLEasy
Which JOIN returns all rows from the left table?
aINNER JOIN
bCROSS JOIN
cLEFT JOIN
dRIGHT JOIN
Explanation: LEFT JOIN keeps every row from the left table.
SQL / MySQLEasy
Which statement permanently saves the changes made in a transaction?
aSAVE
bROLLBACK
cCOMMIT
dEND
Explanation: COMMIT makes the transaction's changes durable; ROLLBACK discards them.
SQL / MySQLEasy
What does `COUNT(*)` count?
aNon-null values
bDistinct values
cColumns
dAll rows
Explanation: COUNT(*) counts rows including NULLs.
SQL / MySQLEasy
Which window function gives the value from the previous row?
aLEAD
bFIRST_VALUE
cPREV
dLAG
Explanation: LAG looks backwards; LEAD looks forwards.
SQL / MySQLEasy
Which keyword removes duplicate rows?
aUNIQUE
bDISTINCT
cDIFFERENT
dSINGLE
Explanation: SELECT DISTINCT removes duplicates.
SQL / MySQLEasy
In `EXPLAIN` output, what does `type = ALL` indicate?
aAll indexes were used
bA full table scan
cThe query returns all columns
dThe result is cached
Explanation: ALL is the worst access type: MySQL reads every row of the table.
SQL / MySQLMedium
Which is best for storing money in MySQL?
aDECIMAL
bFLOAT
cDOUBLE
dVARCHAR
Explanation: DECIMAL avoids floating-point rounding errors.
SQL / MySQLMedium
Scores are 90, 80, 80, 70. What `DENSE_RANK()` (ORDER BY score DESC) does 70 get?
a3
b4
c2
d1
Explanation: DENSE_RANK doesn't leave gaps after ties, so 90→1, 80→2, 80→2, 70→3.
SQL / MySQLMedium
What does this return?
SELECT COALESCE(NULL, 0, 5);
aNULL
b5
cError
d0
Explanation: COALESCE returns the first non-NULL argument.
SQL / MySQLMedium
Why can this query return zero rows even though some customers never ordered?
SELECT name FROM customers
WHERE id NOT IN (SELECT customer_id FROM orders);
aNOT IN only works with numbers
bThe subquery must use DISTINCT
cIf `orders.customer_id` contains a NULL, NOT IN evaluates to unknown for every row
dSubqueries cannot be used in WHERE
Explanation: Any NULL in the list makes `x NOT IN (...)` unknown; use NOT EXISTS instead.
SQL / MySQLMedium
What does this query return?
SELECT name FROM staff
ORDER BY salary DESC
LIMIT 3 OFFSET 2;
aThe three lowest salaries
bThe 3rd, 4th and 5th highest-paid staff
cThe three highest-paid staff
dThree rows in random order
Explanation: OFFSET 2 skips the first two rows of the ordered result, then LIMIT 3 returns the next three.
SQL / MySQLMedium
Which index can MySQL use for `WHERE status = 'PAID'` alone?
a(customer_id, status)
b(created_at, status)
c(customer_id, created_at, status)
d(status, created_at)
Explanation: By the leftmost-prefix rule, only an index starting with `status` helps a filter on status alone.
SQL / MySQLMedium
In MySQL 8, how does `TRUNCATE TABLE orders` differ from `DELETE FROM orders`?
aTRUNCATE only removes rows added today
bTRUNCATE keeps the rows but hides them
cTRUNCATE drops and recreates the table, resets AUTO_INCREMENT and cannot be rolled back
dThere is no difference
Explanation: DELETE removes rows one by one inside a transaction, while TRUNCATE is a DDL statement that resets the table and its AUTO_INCREMENT counter.