CC SQL 5. sorting retrieved Data

  1. sorting data
    • SELECT prod_name
    • FROM products
    • ORDER BY prod_name;
  2. sorting by multiple columns
    • SELECT prod_id, prod_price, prod_name
    • FROM products
    • ORDER BY prod_price, prod_name;

    • It is important to understand that when you are sorting by multiple columns, the sort sequence is exactly as specified. In other words, using the output in the previous example, the products are sorted by the prod_name column only when multiple rows have the same prod_price value. If all the values in theprod_price column had been unique, no data would have been sorted byprod_name.
  3. specifying sort direction
    • SELECT prod_id, prod_price, prod_name
    • FROM products
    • ORDER BY prod_price DESC;
Author
dau108
ID
146220
Card Set
CC SQL 5. sorting retrieved Data
Description
CC SQL 5. sorting retrieved Data
Updated