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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with Query on Multiple Dates

Author  Topic 

cdogstu99
Starting Member

1 Post

Posted - 2011-02-16 : 14:47:41
I have a list of data for stocks. I have created a screen to find stocks based on my criteria. I would like to get the results for my screen for the end of every month for the past two years. For example: I would like the ouptup of my screen on Jan 31, 2010, Feb 28 2010, etc.

Currently my query looks something like this:

Select Ticker, Name, MarketCap, GrowthRate

From MyDatabase

Where Date='12/31/10'

And GrowthRate>10

order by GrowthRate desc

Is there any way to get all of the data i need easily in one query for the last 24 months? So that i will have a table with 24 dates and a list of tickers for each of those dates?


Thanks!

RobertKaucher
Posting Yak Master

169 Posts

Posted - 2011-02-16 : 15:20:35
[CODE]
WHERE DateField IN('20110131', '20101231') AND GrowthRate > 10
ORDER BY GrowthRate DESC
[/CODE]
The problem being the list is now hard coded...

===
http://www.ElementalSQL.com/
Go to Top of Page
   

- Advertisement -