Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

How to update sales of last 3 months only

$
0
0

I have a query which basically updates the sales for the whole year, but i just want that one to be changed such that it only updates for the past 3 months,irrespective of the year ( i mean to say if i run it today it must update march,april,may of 2014 but if i run it on jan 2015 then it must update oct,nov,dec of 2014).

Below is my update statement

update	    tODS_GLBalanceset		tODS_GLBalance.tUTL_JobLogging_Key			=@tUTL_JobLogging_Key,
            tODS_GLBalance.Balance  =  vODS_GLBalance.GLAmount,
            tODS_GLBalance.ModifiedDate = GETDATE(),
            tODS_GLBalance.ModifiedUser		= SUSER_NAME()From       ODS.Staging.vODS_GLBalanceLeftOuterJoin Ods.JJill.tODS_GLBalance ON tODS_GLBalance.FiscalYearId				= vODS_GLBalance.FiscalYearIdAND tODS_GLBalance.FiscalMonthOfYearId		= vODS_GLBalance.FiscalMonthOfYearIdAND tODS_GLBalance.Page                     = vODS_GLBalance.PAGEWhere(tODS_GLBalance.FiscalYearId = YEAR(GETDATE()))AND
	tODS_GLBalance.FiscalMonthOfYearId  = vODS_GLBalance.FiscalMonthOfYearIdAND tODS_GLBalance.FiscalYearId = vODS_GLBalance.FiscalYearIdAND tODS_GLBalance.Page = vODS_GLBalance.PageAND tODS_GLBalance.Balance <>  vODS_GLBalance.GLAmount

Can someone please help me with this, Please let me know if you have any questions or if i am unclear.

Thanks


Viewing all articles
Browse latest Browse all 23857

Trending Articles