0

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.

xxlali
  • 996
  • 2
  • 15
  • 43
  • Try http://stackoverflow.com/questions/17762639/sql-order-by-not-working-properly I think it can help – CodeSikh Aug 17 '15 at 12:55

1 Answers1

1

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.

Ankit Agrahari
  • 349
  • 9
  • 22