|
infodemers
Posting Yak Master
Canada
168 Posts |
Posted - 09/26/2012 : 18:35:48
|
Hi, I have to run a query to get the Treshold values for a range of date. Like--> Select Treshold from table1 where([Date] >= '2012-01-01' and [Date] <= '2012-09-01') or ([Date] >= '2011-01-01' and [Date] <= '2011-09-01')
For every results, I would need to have it like this
------------------------------------------------ Treshold(for 2011-01-01)|Treshold(for 2012-01-01) ------------------------------------------------- Treshold(for 2011-02-01)|Treshold(for 2012-02-01) ------------------------------------------------- Treshold(for 2011-03-01)|Treshold(for 2012-03-01) -------------------------------------------------
Thanks ! |
|
|
infodemers
Posting Yak Master
Canada
168 Posts |
Posted - 09/26/2012 : 21:11:35
|
Never mind everyone,
I found out a way of getting it done.
Select t2.Treshold as PreviousTreshold, t1.Treshold from table1 t1 left outer join (Select Treshold from table1 Where (t2.[Date] >= '2011-01-01' and t2.[Date] <= '2011-09-01')) as t2 on Month(t2.date) = Month(t1.date) where (t1.[Date] >= '2012-01-01' and t1.[Date] <= '2012-09-01') |
 |
|