Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query 2 dates values results on same row
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

183 Posts

Posted - 09/26/2012 :  18:35:48  Show Profile  Reply with Quote
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 !

Posting Yak Master

183 Posts

Posted - 09/26/2012 :  21:11:35  Show Profile  Reply with Quote
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( = Month(
where (t1.[Date] >= '2012-01-01' and t1.[Date] <= '2012-09-01')
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000