← 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. By default, in which direction does ORDER BY sort results?

    Answer: Ascending (ASC)

    ORDER BY sorts in ascending order by default unless DESC is specified.

  2. Which clause limits the number of rows returned in standard MySQL/PostgreSQL?

    Answer: LIMIT

    LIMIT restricts the number of rows returned in MySQL and PostgreSQL.

  3. How do you sort by 'last_name' ascending and then 'first_name' descending?

    Answer: ORDER BY last_name ASC, first_name DESC

    Each column in ORDER BY can have its own sort direction.

  4. In SQL Server, which keyword limits the number of rows returned?

    Answer: TOP

    SQL Server uses TOP n to restrict the number of returned rows.

  5. What does ORDER BY 2 mean in a query?

    Answer: Sort by the second column in the SELECT list

    A number in ORDER BY refers to the position of a column in the SELECT list.

  6. Which query returns rows 11–20 in PostgreSQL?

    Answer: LIMIT 10 OFFSET 10

    OFFSET 10 skips the first 10 rows and LIMIT 10 returns the next 10.

  7. Without an ORDER BY clause, the order of returned rows is:

    Answer: Not guaranteed

    Row order is undefined unless ORDER BY is used.