โ† 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. Can you use a column alias defined in SELECT inside ORDER BY?

    Answer: Yes, in most databases

    ORDER BY runs after SELECT, so column aliases are usable there.

  2. Which query finds the top 3 highest-priced products?

    Answer: ORDER BY price DESC LIMIT 3

    Sorting price descending and limiting to 3 returns the most expensive items.

  3. What is the risk of using LIMIT/OFFSET for pagination on large tables?

    Answer: Large offsets get slower as they scan and skip rows

    High OFFSET values force the database to scan and discard many rows, hurting performance.

  4. Which expression sorts case-insensitively in many databases?

    Answer: ORDER BY LOWER(name)

    Applying LOWER() to the column normalizes case before sorting.

  5. Can ORDER BY use an expression like ORDER BY price * quantity?

    Answer: Yes, expressions are allowed

    ORDER BY accepts arbitrary expressions, not just plain columns.

  6. In SQL Server, how do you get the top 10 percent of rows?

    Answer: SELECT TOP 10 PERCENT

    SQL Server supports TOP n PERCENT to return a percentage of rows.

  7. Which clause combination is required for reliable pagination?

    Answer: ORDER BY with LIMIT/OFFSET

    Without ORDER BY, pagination results can vary between queries.