sql - How to select next date from table in teradata -


i have table containing following info

quarter_end_date | flag  2014/31/03       |  n  2014/30/06       |  y  2014/30/09       |  n  2014/31/12       |  n  

and on....

whenever query run should update next quarter flag y , previous n

please provide solution implement this.

update next quarter's flag y (assume there 1 y flag in table):

update [table_name] set flag = 'y' quarter_end_date = dateadd(day, 90, (    select first(quarter_end_date)    [table_name]    flag = 'y')); 

update previous quarter's flag n:

update [table_name] set flag = 'n' quarter_end_date = (    select min(quarter_end_date)    [table_name]    flag = 'y')); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -