sql server 2008 - How we find Latest Date value and update in another column in Sql? -


i have thee column date values there have update fourth column latest date value

so please me write update query in sql server:

   date1       date2        date3      latest date 11/24/1991   1/14/2003    11/24/1991    1/14/2003 

try this

update  tablename set     latestdate = ( select   case when date1 >= date2                                           , date1 >= date3 date1                                      when date2 >= date1                                           , date2 >= date3 date2                                      when date3 >= date1                                           , date3 >= date2 date3                                      else date1                                 end                      )  

and don't forget add condition


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -