SQL DESC

Sorts largest-to-smallest — must be written explicitly, since it's never the default.

What & Why

DESC reverses the sort direction — largest-to-smallest for numbers, Z-to-A for text. Unlike ASC, this one always needs to be written out.

See How It Works

idnamechannelspendstart_dateend_datestatustarget_segment
1Spring Launchgoogle_ads55000.002024-01-152024-03-31activesmb
2Retention Webinaremail45000.002024-02-102024-04-15activeenterprise
3Finance Retargetinglinkedin50000.002024-03-122024-05-31activeenterprise
4Enterprise Searchgoogle_ads60000.002024-04-012024-06-30activeenterprise
EXAMPLE QUERY
SELECT name, spend FROM marketing.campaigns
ORDER BY spend DESC;
RESULT
namespend
Enterprise Search60000.00
Spring Launch55000.00
Finance Retargeting50000.00
Retention Webinar45000.00

The result uses the same Queryflo columns shown in the worked example.

Now You Try

Practice this concept

Marketing wants campaigns sorted from the highest spend to the lowest spend.

Available schema
marketing

Prefix tables with marketing.table_name.

namespend
marketing.campaigns
ColumnType
idinteger
nametext
channeltext
spendnumeric
start_datedate
end_datedate
statustext
target_segmenttext
legacy_idtext
query.sql
Beginner business practice

Sign up free to try it on a real business scenario