Sort Up, Sort Down
You can specify a direction—low to high or high to low—for each sort by using the ascending (ASC) or descending (DESC) keyword immediately after the sort item. Ascending is the default, assumed to be in effect unless you type DESC, which means you don't really need to use ASC except to make the direction of the sort unavoidably explicit to others who read the query.
Here's how you'd get pub_ids to display in descending order:
SQLselect title_id, pub_id, price * ytd_sales as Income, price from titles where type in ('business', 'psychology') order by pub_id desc, price desc title_id pub_id Income price ======== ====== ============== ========== BU1032 1389 122809.05 29.99 BU7832 1389 122809.05 29.99 BU1111 1389 85078.20 21.95 ...
Get Practical SQL Handbook, The: Using SQL Variants, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.