Order By TSQL Tutorial

Order By Example:

CONTRACT_IDCUSTOMER_IDAMOUNT
11400
22500
33700
411000
521200
64900
732000
821500

SELECT c.customer_id, c.amount
   FROM contracts c
  WHERE c.amount < 2500
GROUP BY c.customer_id, c.amount
HAVING MIN(c.amount) > 1000
ORDER BY c.amount ;

Customer_IdAmount
21200
21500
32000

SELECT c.customer_id, c.amount
   FROM contracts c
  WHERE c.amount < 2500
GROUP BY c.customer_id, c.amount
HAVING MIN(c.amount) > 1000
ORDER BY c.amount DESC;

Customer_IdAmount
32000
21500
21200