You didnt give the sample dataRefer thisDeclare @t table(h_BOND_PD_RA varchar(10),h_LI_PERIOD5 varchar(10),ReportDate datetime, h_MATURITY datetime, h_band varchar(100))insert into @t Select '5','1',getdate()-1655,getdate(),'' IF exists (SELECT h_BOND_PD_RA, h_LI_PERIOD5 FROM @t WHERE ((h_BOND_PD_RA >= N'3') OR (h_LI_PERIOD5 >= N'3')))BEGIN UPDATE @t SET h_band = '4 to 5 years' WHERE (DATEDIFF(day, ReportDate, h_MATURITY) / 30.4167 > '48') AND (DATEDIFF(day, ReportDate, h_MATURITY) / 30.4167 <= '60') ENDELSE UPDATE @t SET h_band = '4,3 to 5,7 years' WHERE (DATEDIFF(day, ReportDate, h_MATURITY) / 30.4167 > '51.599') AND (DATEDIFF(day, ReportDate, h_MATURITY) / 30.4167 <= '68.399')select * from @t
MadhivananFailing to plan is Planning to fail