โ† All SQL Flashcard Decks

Sorting and Limiting Results Flashcards

7 cards from real SQL practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Sorting and Limiting Results flashcards as text
  1. How are NULL values typically sorted in PostgreSQL ascending order by default?

    Answer: NULLs appear last

    In PostgreSQL ascending order, NULLs are treated as larger and sort last by default.

  2. Which clause forces NULL values to appear first in PostgreSQL?

    Answer: ORDER BY col NULLS FIRST

    NULLS FIRST explicitly places NULL values before non-NULL values.

  3. Can you ORDER BY a column that is not in the SELECT list?

    Answer: Yes, in most databases

    Most databases allow sorting by columns not included in the SELECT list.

  4. Which standard SQL clause limits rows using FETCH?

    Answer: FETCH FIRST n ROWS ONLY

    FETCH FIRST n ROWS ONLY is the ANSI SQL standard for limiting rows.

  5. What does ORDER BY salary DESC, hire_date ASC do?

    Answer: Highest salary first, ties broken by earliest hire date

    Primary sort is salary descending; ties are resolved by hire_date ascending.

  6. In MySQL, what does LIMIT 5 with no OFFSET return?

    Answer: The first 5 rows

    LIMIT 5 returns the first five rows of the result set.

  7. Which is valid MySQL shorthand for OFFSET 20 LIMIT 10?

    Answer: LIMIT 20, 10

    MySQL's two-argument LIMIT takes offset first, then row count.

Sorting and Limiting Results Flashcards โ€” SQL Study Cards with Answers