+ 2

ORDER BY ______ ;🆚 ORDER BY ______ ASC;

Hello everybody, According to this “By default, the ORDER BY keyword sorts the results in ascending order.” So my question regarding this is, how different are ORDER BY ______ ; and ORDER BY ______ ASC;? And which one is the best to use and why? Thanks

26th Jun 2020, 10:37 PM
Mohamed Assaleh
Mohamed Assaleh - avatar
5 odpowiedzi
+ 2
You can sort the result either ascending or descending. None is better than the other. It depends on the case specific requirements. If you e.g. want to request the highest test results, descending order of total points column is useful. If you want a list of friends who have birthday within the next month, ascending order by name or date of birth is more helpful.
26th Jun 2020, 10:45 PM
Sandra Meyer
Sandra Meyer - avatar
+ 2
I'm not an SQL specialist too. Just I want to share some reflections. I think, It may be interesting when you order data without unique key, so you will have duplicated rows or objects. Same name field for example.
26th Jun 2020, 11:22 PM
Dhafer ABDELKADER
Dhafer ABDELKADER - avatar
+ 2
Ordering the result does not affect the total number of results and doesn't create duplicate values.
26th Jun 2020, 11:31 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
Mohamed Assaleh The ORDER BY keyword sorts the records in ascending order by default. 
26th Jun 2020, 11:23 PM
BroFar
BroFar - avatar
+ 1
I generally just use the standard ORDER BY ______; and have not experienced getting duplicate records or values todate
26th Jun 2020, 11:39 PM
BroFar
BroFar - avatar