Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ORDER BY a concatenated name in Oracle?

I have a table called USERS from which I'm getting an employee's first and last name, and printing them out as one name. How do I use ORDER BY correctly on this data?

Here's what I have:

SELECT l.OFFICE_NAME, (us.LAST_NAME || ' , ' || us.FIRST_NAME) AS "Employee Name"
FROM LOCAL_OFFICE l, USERS us
WHERE l.LOCAL_OFFICE_ID = us.LOCAL_OFFICE_ID
ORDER BY  l.OFFICE_NAME  --what do I place here?--

I will do this through a JOIN instead of the more expensive FROM, but how do I order by the name alphabetically?

like image 273
null Avatar asked Nov 29 '22 18:11

null


1 Answers

You can say:

ORDER BY office_name, "Employee Name"

That works in 11G, but maybe not in older version of Oracle.

like image 109
Tony Andrews Avatar answered Dec 01 '22 07:12

Tony Andrews