Revenue Ladder, Unknowns Last

Intermediate

Finance is building a revenue ladder from the smallest customer to the largest. Accounts with no revenue figure should sit at the bottom, not the top.

Return the Name of every Account ordered by AnnualRevenue from smallest to largest, with accounts that have no revenue value at the end.

Sample data

Account 4 records

NameAnnualRevenue
Acme Cloud5,000,000
Bluefin Banknull
Corex Labs1,200,000
Delta Retail9,000,000

Expected result on the sample

Name
Corex Labs
Acme Cloud
Delta Retail
Bluefin Bank

Row order matters for this problem. Only the columns above are compared; extra columns in your SELECT are fine.

Hints
  • Ascending is the default direction.
  • Add NULLS LAST after the sort direction.

What this tests

In an ascending sort, SOQL puts null values first by default. NULLS LAST moves them to the end without a second query or any Apex. Forgetting it is a common reason a sorted list "looks wrong" in a report or a Lightning table.

SOQL

Run on sample executes your query against the sample data shown on the left and displays the rows it returns. Submit checks it against the sample plus 2 hidden datasets, comparing your rows with the expected rows on each. Queries run in a real Salesforce org; the data is inserted for your run and rolled back afterwards.