if Statement

Last Post 03 Feb 2010 08:24 AM by JASBRYDEN. 1 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
JASBRYDEN
New Member
New Member

--
03 Feb 2010 06:49 AM
I have this SQL script.

But I want to add a IF to it.

so that IF year ='2008' then do script 1

if year =' 2009 then do script 1

How do I get that ?

script 1
update asb_vsafcdt
set averagecost=(select averagecost from asb_averagecost
where
asb_averagecost.itemno=asb_vsafcdt.itemno and
asb_averagecost.[year]=asb_vsafcdt.forecast_year and
asb_averagecost.[month]=dateadd (mm,1,forecast_date) )
where exists
(select averagecost from asb_averagecost
where
asb_averagecost.itemno=asb_vsafcdt.itemno and
asb_averagecost.[year]=asb_vsafcdt.forecast_year and
asb_averagecost.[month]=dateadd (mm,1,forecast_date) )
JASBRYDEN
New Member
New Member

--
03 Feb 2010 08:24 AM
lol


well that would work as well.


But since my talbe has five dates from 2007 to 2011

I was thinking to use a IF statement.

But I suppose the where[year]=2008 would work fine.



Acceptable Use Policy
---