Reputation: 1046
I want to use order by
command on a table to get timestamps in order. But it does not give the result I expect. For example;
select * from my_table order by tstmp desc;
I gives the result something like;
my_table.tstmp
--------------
100
98
45
150
145
What is the reason of this and how can I fix this?
Thank you.
Upvotes: 0
Views: 380
Reputation: 379
If you are taking datatype as timestamp for the column my_table.tstmp than it should contain format yyyy-mm-dd hh:mm:ss .If they are in another format declare them as the appropriate type (INT, FLOAT, STRING, etc.) and use a UDF to convert them to timestamps. And than apply your sorting.
Upvotes: 1