monocular
monocular

Reputation: 323

Order by the greater column

I have two column for stored time named : Time_1 | Time_2

I want to make a SQL query that select all table, then order the result by compare between Time_1 vs Time_2 to get the greater (newer) value of each row and order all result by that greater value.

Upvotes: 0

Views: 39

Answers (1)

juergen d
juergen d

Reputation: 204894

select * from your_table
order by case when Time_1 >= Time_2 then Time_1 
              else Time_2
         end desc

Upvotes: 2

Related Questions