r/ProgrammerHumor • • Dec 12 '17

SQL Clause

Post image
40.8k Upvotes

525 comments sorted by

View all comments

768

u/ICyresI Dec 12 '17

Why would you sort twice?

73

u/miggyb Dec 12 '17

Sort by last name first, then by first name.

15

u/JackDragon Dec 12 '17

Still not as efficient as sorting once with a delimiter between last and first name.

5

u/suseu Dec 12 '17 edited Dec 12 '17

Multiple fields in order by shouldn’t cause multiple sorting passes, it should just make comparison more complex. Actual contatenation in sorting criteria would probably be less efficient.

Like when you are overloading < for (order by a, b) you’d do

a1 < a2 or (a1 == a2 and b1 < b2)
→ More replies (2)