postgresql - Increment month number by 1 SQL -


i need update column value incrementing 1, column month_number , defined integer, when month 12, need update 1 instead of 13

i first tried approach:

update tab set col_month = col_month + 1 

but won't work cases col_month 12

here's 1 method using case statement:

update tab set col_month = case when col_month = 12 1 else col_month + 1 end 

Comments