Re: getting sum of units sold in preceeding weeks
From: Vishal Parkar (REMOVE_THIS_vgparkar_at_yahoo.co.in)
Date: 05/11/04
- Next message: Nikhil: "Re: getting sum of units sold in preceeding weeks"
- Previous message: Vishal Parkar: "Re: Third largest salary"
- In reply to: Nikhil: "Re: getting sum of units sold in preceeding weeks"
- Next in thread: Nikhil: "Re: getting sum of units sold in preceeding weeks"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 11 May 2004 15:29:56 +0530
>>it should not add the 1st preceeding week unitssold...<<
yes, it will not add 1st preceding week's unitssold, All you have to do is
pass right parameter to dateadd function in the query i've posted.
ex:
select sum(case when dt_column >= dateadd(dd, -7, {fn current_date()} )and
dt_column <= getdate() then sold_units else 0 end) 'last week',
sum(case when dt_column >= dateadd(dd, -15, {fn current_date()} ) and
dt_column < dateadd(dd, -8, {fn current_date()} ) then sold_units else 0
end) '2nd last week'
from
<table_name>
If this doesn't satisfy your requirement , pls post table structure and
sample records and expected result set.
--
Vishal Parkar
vgparkar@yahoo.co.in | vgparkar@hotmail.com
- Next message: Nikhil: "Re: getting sum of units sold in preceeding weeks"
- Previous message: Vishal Parkar: "Re: Third largest salary"
- In reply to: Nikhil: "Re: getting sum of units sold in preceeding weeks"
- Next in thread: Nikhil: "Re: getting sum of units sold in preceeding weeks"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|