1. What order do rows come back in without ORDER BY?
- Primary key order
- Insertion order
- No guaranteed order
- Alphabetical order
जवाब देखें
जवाब: No guaranteed order
Always add ORDER BY when order matters.
पाठ: Thinking in Sets
SQL Deep Dive कोर्स के 25 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।
जवाब: No guaranteed order
Always add ORDER BY when order matters.
पाठ: Thinking in Sets
जवाब: HAVING
HAVING runs after GROUP BY.
जवाब: UNKNOWN (NULL)
Use IS NULL or IS NOT DISTINCT FROM.
जवाब: Unmatched left rows are removed, like an inner join
NULL fails the WHERE condition.
जवाब: If the subquery returns a NULL, every NOT IN comparison is unknown
Use NOT EXISTS instead.
जवाब: Aggregate at the order grain before joining, or avoid the unneeded join
Match the grain to the metric.
जवाब: The number of rows in each group hired since 2022
Conditional aggregation.
जवाब: 1
It identifies aggregated levels.
जवाब: Half-open ranges avoid gaps and double counting at boundaries
Works for dates and timestamps.
जवाब: RANK
1, 2, 2, 4.
जवाब: LAG
LEAD looks forward.
जवाब: The total salary of that row's department
No ORDER BY means the whole partition.
जवाब: An anchor query and a recursive query joined to the previous results
Combined with UNION ALL.
जवाब: LEFT JOIN LATERAL (...) ON true
Like any left join.
पाठ: LATERAL Joins
जवाब: EXCEPT
Set difference.
जवाब: LEFT JOIN orders to a generated list of days and COALESCE the sum to 0
Start from the complete calendar.
जवाब: The date minus its row number
That difference is the island key.
पाठ: Gaps and Islands
जवाब: A unique constraint or unique index on the key
Let the database enforce it.
जवाब: INSERT ... ON CONFLICT DO UPDATE
Atomic with respect to concurrent inserts.
पाठ: MERGE and Upserts
जवाब: Returns the modified rows, like a SELECT
Great for audits and verification.
जवाब: Undoes all changes made since BEGIN
Nothing is permanent until COMMIT.
जवाब: The function changes the column, so the index order on raw values cannot be used directly
Use a range or an expression index.
जवाब: WHERE kind = 'buy'
Leftmost prefix rule.
जवाब: It executes the query and reports actual row counts
Estimated versus actual.
जवाब: Use NOT EXISTS rather than NOT IN with nullable subqueries
NULL-safe anti-joins.