geek2000
geek2000

Reputation: 481

Get the max date from each ROW

I have this table:

enter image description here

How can I get the MAX date for each ID from each row?

Upvotes: 0

Views: 106

Answers (1)

Juan Carlos Oropeza
Juan Carlos Oropeza

Reputation: 48177

Use Greatest

 SELECT id, GREATEST (date1, date2, date3)
 FROM YourTable

Note that GREATEST and LEAST are not in the SQL standard, but are a common extension. Some other databases make them return NULL if any argument is NULL, rather than only when all are NULL.

Upvotes: 1

Related Questions