Reputation: 95
I store bike name and their prices. Now I want show all my bikes ordered with maximum price (most expensive) first, as in:
bike 800 cc 1600$
bike 400 cc 800$
bike 200 cc 400$
bike 100 cc 200$
Upvotes: 2
Views: 280
Reputation:
SELECT * FROM bikes ORDER BY price DESC
check if datatype of price column is varchar then it will not work properly. So use below trick:
SELECT * FROM bikes ORDER BY price+0 desc
This is a quick fix instead of sorting to CAST operator.
Upvotes: 3