Bird
Raised Fist0
Google Sheetsspreadsheet~15 mins

ORDER BY clause in Google Sheets - Real Business Scenario

Choose your learning style10 modes available
Scenario Mode
👤 Your Role: You are a sales analyst at a retail company.
📋 Request: Your manager wants a sorted list of products by their total sales to identify the best-selling items.
📊 Data: You have a table with product names, units sold, and unit price for each product.
🎯 Deliverable: Create a sorted list of products ordered by total sales (units sold multiplied by unit price) from highest to lowest.
Progress0 / 3 steps
Sample Data
ProductUnits SoldUnit Price
Notebook1202.50
Pen3001.20
Backpack8025.00
Calculator5015.00
Marker2001.50
Folder1503.00
Stapler607.00
Highlighter1801.80
1
Step 1: Add a new column named 'Total Sales' next to 'Unit Price'. Calculate total sales by multiplying 'Units Sold' by 'Unit Price' for each product.
=B2*C2
Expected Result
For Notebook, total sales = 120 * 2.50 = 300
2
Step 2: Copy the formula down the 'Total Sales' column for all products.
Drag the fill handle from D2 down to D9
Expected Result
Pen total sales = 300 * 1.20 = 360; Backpack total sales = 80 * 25.00 = 2000, etc.
3
Step 3: Create a new table that sorts the products by 'Total Sales' in descending order using the SORT function.
=SORT(A2:D9, 4, FALSE)
Expected Result
Backpack appears first with 2000 total sales, followed by Calculator with 750, Folder with 450, etc.
Final Result
Product     Units Sold  Unit Price  Total Sales
---------------------------------------------
Backpack    80          25.00       2000
Calculator  50          15.00       750
Folder      150         3.00        450
Stapler     60          7.00        420
Pen         300         1.20        360
Highlighter 180         1.80        324
Notebook    120         2.50        300
Marker      200         1.50        300
✓Backpack is the best-selling product with total sales of 2000.
✓Pen and Calculator also have strong sales.
✓Sorting by total sales helps quickly identify top products.
Bonus Challenge

Modify the sorted list to show only products with total sales greater than 300.

Show Hint
Use the FILTER function combined with SORT, like SORT(FILTER(range, condition), column, FALSE).

Practice

(1/5)
1. What does the ORDER BY clause do inside a Google Sheets QUERY function?
easy
A. Filters rows based on a condition
B. Sorts the data by a specified column
C. Adds new columns to the data
D. Deletes duplicate rows

Solution

  1. Step 1: Understand the purpose of ORDER BY

    The ORDER BY clause is used to sort data in a query result.
  2. Step 2: Identify what sorting means

    Sorting arranges rows based on values in a chosen column, either ascending or descending.
  3. Final Answer:

    Sorts the data by a specified column -> Option B
  4. Quick Check:

    ORDER BY = Sort data [OK]
Hint: ORDER BY always sorts data by column [OK]
Common Mistakes:
  • Thinking ORDER BY filters rows
  • Confusing ORDER BY with adding columns
  • Assuming ORDER BY removes duplicates
2. Which of the following is the correct syntax to sort data by column B in ascending order using QUERY in Google Sheets?
easy
A. =QUERY(A1:C10, "SELECT * ORDER BY B DESC")
B. =QUERY(A1:C10, "SELECT * ORDER BY B DOWN")
C. =QUERY(A1:C10, "SELECT * ORDER BY B ASC")
D. =QUERY(A1:C10, "SELECT * ORDER BY B UP")

Solution

  1. Step 1: Recall correct ORDER BY syntax

    In QUERY, ascending order is specified by ASC, descending by DESC.
  2. Step 2: Check each option

    =QUERY(A1:C10, "SELECT * ORDER BY B ASC") uses ORDER BY B ASC which is correct syntax for ascending order. Options B and C use invalid keywords DOWN and UP. =QUERY(A1:C10, "SELECT * ORDER BY B DESC") sorts descending, not ascending.
  3. Final Answer:

    =QUERY(A1:C10, "SELECT * ORDER BY B ASC") -> Option C
  4. Quick Check:

    ASC means ascending order [OK]
Hint: Use ASC for ascending, DESC for descending [OK]
Common Mistakes:
  • Using DOWN or UP instead of ASC or DESC
  • Mixing ascending and descending keywords
  • Forgetting quotes around the query string
3. Given the data in A1:B4:
A    Score
John  85
Anna  92
Mike  78
Sara  90

What will be the result of =QUERY(A1:B4, "SELECT A, B ORDER BY B DESC")?
medium
A. John 85
Sara 90
Anna 92
Mike 78
B. Sara 90
Anna 92
John 85
Mike 78
C. Mike 78
John 85
Sara 90
Anna 92
D. Anna 92
Sara 90
John 85
Mike 78

Solution

  1. Step 1: Understand ORDER BY B DESC

    The query sorts rows by column B (Score) in descending order, highest to lowest.
  2. Step 2: Sort the scores

    Scores sorted descending: 92 (Anna), 90 (Sara), 85 (John), 78 (Mike).
  3. Final Answer:

    Anna 92
    Sara 90
    John 85
    Mike 78
    -> Option D
  4. Quick Check:

    DESC sorts highest to lowest [OK]
Hint: DESC sorts from highest to lowest [OK]
Common Mistakes:
  • Confusing ascending and descending order
  • Not sorting by the correct column
  • Ignoring the header row in output
4. You wrote this formula: =QUERY(A1:C10, "SELECT A, B ORDER BY C DESCENDING") but it gives an error. What is the problem?
medium
A. The keyword should be DESC, not DESCENDING
B. You cannot order by column C
C. The SELECT clause must include column C
D. The query string must be lowercase

Solution

  1. Step 1: Check ORDER BY syntax

    The correct keyword for descending order is DESC, not DESCENDING.
  2. Step 2: Validate other parts

    Ordering by column C is allowed even if not selected. Query strings are case-insensitive, so lowercase is fine but not required.
  3. Final Answer:

    The keyword should be DESC, not DESCENDING -> Option A
  4. Quick Check:

    Use DESC for descending order [OK]
Hint: Use DESC, not DESCENDING for descending order [OK]
Common Mistakes:
  • Typing DESCENDING instead of DESC
  • Thinking ORDER BY column must be selected
  • Assuming query strings must be lowercase
5. You have a table with columns: Name, Age, and Score. You want to list all names and scores sorted by Age ascending, then Score descending. Which QUERY formula is correct?
hard
A. =QUERY(A1:C10, "SELECT A, C ORDER BY B ASC, C DESC")
B. =QUERY(A1:C10, "SELECT A, C ORDER BY C DESC, B ASC")
C. =QUERY(A1:C10, "SELECT A, B ORDER BY B ASC, C DESC")
D. =QUERY(A1:C10, "SELECT A, C ORDER BY B DESC, C ASC")

Solution

  1. Step 1: Identify columns and order

    We want to select Name (A) and Score (C). Sort first by Age (B) ascending, then Score (C) descending.
  2. Step 2: Match query syntax

    =QUERY(A1:C10, "SELECT A, C ORDER BY B ASC, C DESC") selects A and C, orders by B ASC (Age ascending), then C DESC (Score descending). Other options either select wrong columns or order incorrectly.
  3. Final Answer:

    =QUERY(A1:C10, "SELECT A, C ORDER BY B ASC, C DESC") -> Option A
  4. Quick Check:

    ORDER BY multiple columns works left to right [OK]
Hint: Order by multiple columns separated by commas [OK]
Common Mistakes:
  • Selecting wrong columns in SELECT clause
  • Reversing order directions
  • Ordering by columns not selected
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard