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
 SQL Excel Query

Author  Topic 

TheJudge
Starting Member

2 Posts

Posted - 2007-11-11 : 13:21:08
Can someone please help?

My access database downloads the last 6 months stock market data i.e close, high, low price. However, I want to show the results in Excel but only the last three values for each stock (as I have over 1000 stocks).

For example:

qDate qTicker qOp qHi qLo qCl qVo
08/11/2006 AAT.L 98 100 98 99 2361001
09/11/2006 AAT.L 98 98 98 98 378001
10/11/2006 AAT.L 99 99 97 97 66001

08/11/2006 VOD.L 198 100 198 199 2361020
09/11/2006 VOD.L 198 198 198 198 378020
10/11/2006 VOD.L 199 199 197 197 66010

08/11/2006 ARM.L 298 200 298 299 1236100
09/11/2006 ARM.L 298 298 298 298 317800
10/11/2006 ARM.L 299 299 297 297 66100

but instead it displays the last 6 months data for every stock to the point where it is unable to display anymore records in Excel.

Does anyone have any SQL code to resolve this?

Thanks!


dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-11 : 13:36:25
If you are using MS QUery to feed the excel sheet you can add a filter like this on the qDate column

>=dateadd(d,-3,getdate())
Go to Top of Page

TheJudge
Starting Member

2 Posts

Posted - 2007-11-11 : 13:40:58
I'm not worried about the 65k limit as I don't need to use it that many rows. I connect to my access database by using excel’s "new database query". I then access the Microsoft Query program where it gives me the option to amend the SQL.
Go to Top of Page

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2007-11-11 : 13:48:12
Try the filter I posted, I changed my response. At first I thought it was not a SQL problem, but as a frequent user of MS Query and the SQL therein, I figured you might gather the data that way..
Go to Top of Page
   

- Advertisement -