September 16, 2010 at 11:20 am
HI HAVE WRITTEN A CNDITION LIKE THIS.
select cast(right(201008,2) + '/01/' + left(201008,4) as datetime), ARD.PeriodMonth,RMP.StartMonth, RMP.EndMonth,RMP.StartDate, RMP.EndDate from Report.AggResponseData ard
inner join Report.refMonPeriod RMP ON
(cast(right(ARD.PeriodMonth,2) + '/01/' + left(ARD.PeriodMonth,4) as datetime)
BETWEEN
(select StartDate as 'RP Start Date' from [IAG].[Report].[refMonPeriod] where periodid = 8) and
(select (dateadd(m,11,enddate)) as 'RP End Date' from [IAG].[Report].[refMonPeriod] where periodid = 8) )
whatever the period id i give it is returing all the periods tresspective og whether taht date lies in between teh selected range or not.
Can join on bewteen condition.
please let m eknow the error
if i put RMP.PeriodID =8 instead of PeriodID=8 Then it says an error that sub query returned more tahn one value.
i have to finish this task today. please help me out.
Thank you
thank you.
September 16, 2010 at 11:40 am
BETWEEN requires a pair of values;
BETWEEN X AND Y
your query:
select StartDate as 'RP Start Date' from [IAG].[Report].[refMonPeriod] where RMP.periodid = 8
returns more than one row...if you cahnge it to select the min or the TOP 1, it should work:
select MIN(StartDate) as 'RP Start Date' from [IAG].[Report].[refMonPeriod] where RMP.periodid = 8
select TOP 1 StartDate as 'RP Start Date' from [IAG].[Report].[refMonPeriod] where RMP.periodid = 8
the same is true for your calculation of the end date.
Lowell
September 17, 2010 at 10:39 am
THANKS FOR REPLYING ME.
In the between clause it is returing only one value not more than one.
it just returns the start date and end date of that period.
I have not got the solution for this.
please help me out with this.
Thank you
September 17, 2010 at 11:01 am
whetehr you beleive it or not, it's returning more than one value:
if i put RMP.PeriodID =8 instead of PeriodID=8 Then it says an error that sub query returned more than one value.
did you try changing your code to the example i posted? what happened?
Lowell
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply