I have the following piece of code that needs the last month added manually each month when it is run.
I'm sure there must be a way to do this automatically ?
The last month is always 'last month' (ie if its May now, then its April)
There must be a better way of writing the above, using the logic :
"Select all months + year from May99 to last month, make all = '' except last month =h.Grp" ??
Any ideas ?
I'm sure there must be a way to do this automatically ?
Code:
Insert into Migration
Select h.PersonNo,
'May99' = '',
'Jun99' = '',
'Jul99' = '',
'Aug99' = '',
'Sep99' = '',
'Oct99' = '',
'Nov99' = '',
'Dec99' = '',
'Jan00' = '',
'Feb00' = '',
'Mar00' = '',
'Apr00' = '',
'May00' = '',
'Jun00' = '',
'Jul00' = '',
'Aug00' = '',
'Sep00' = '',
'Oct00' = '',
'Nov00' = '',
'Dec00' = '',
'Jan01' = '',
'Feb01' = '',
'Mar01' = '',
'Apr01' = '',
'May01' = '',
'Jun01' = '',
'Jul01' = '',
'Aug01' = '',
'Sep01' = '',
'Oct01' = '',
'Nov01' = '',
'Dec01' = '',
'Jan02' = '',
'Feb02' = '',
'Mar02' = '',
'Apr02' = '',
'May02' = '',
'Jun02' = '',
'Jul02' = '',
'Aug02' = '',
'Sep02' = '',
'Oct02' = '',
'Nov02' = '',
'Dec02' = '',
'Jan03' = '',
'Feb03' = '',
'Mar03' = '',
'Apr03' = '',
'May03' = '',
'Jun03' = '',
'Jul03' = '',
'Aug03' = '',
'Sep03' = '',
'Oct03' = '',
'Nov03' = '',
'Dec03' = '',
'Jan04' = '',
'Feb04' = '',
'Mar04' = '',
'Apr04' = h.Grp --// Roll this down every month
from HC_Segment h
The last month is always 'last month' (ie if its May now, then its April)
There must be a better way of writing the above, using the logic :
"Select all months + year from May99 to last month, make all = '' except last month =h.Grp" ??
Any ideas ?