Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ORDER BY timestamp column as a string

user2269823May 28 2009 — edited May 28 2009
Does any one have any tips/tricks for using an ORDER BY clause for a timestamp column that is a string?

I am developing a UNION query that combines data from a table and an audit history table to show current data plus historical data.

I had to convert the timestamp column to a string so the datatypes would match for the UNION query, but now they ORDER BY clause does not work.

For example:

SELECT
location,
'CURRENT' as VALID_DATE
FROM
person

UNION

SELECT
location,
TO_CHAR(audit_date)
FROM
person_audit

ORDER BY 2 DESC
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 25 2009
Added on May 28 2009
5 comments
9,376 views