Can we use aliased field name in ORDER BY
clause?
For example:
SELECT id, name AS firstname
FROM users
ORDER BY firstname
Is it possible? When I tried this it errored out.
An alias can be used in a query select list to give a column a different name. You can use the alias in GROUP BY, ORDER BY, or HAVING clauses to refer to the column.
Check here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With