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
 arrays of same size

Author  Topic 

Lyriclover
Starting Member

8 Posts

Posted - 2010-02-18 : 15:19:37
Hi there, I'm wondering how I might got about fixing a problem I'm having using arrays.

I have the following code (I have additional SQLs for the other years 08, 09, 10, 11 with the same code, respectively):

***********************************
CISMAprB07 = "SELECT [ISMpm]-[Apr] AS ISMAprBasis FROM ChartPrice where ISMpm >0 AND Apr >0 AND Date >= #2007/4/16#-90 AND Date <= #2007/4/16# order by Date;"
Call rs.Open(CISMAprB07,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\WebDev\Db\WebDb.mdb;")
Set dbTable = cd.DBTable(rs)
rs.Close()

CISMAprB07y = dbTable.getCol(0)
***********************************

This code actually works (no errors) and ChartDirector will chart them as I'd expect, except that due to each year having a different numbers of days, holidays falling on different days each year, etc, my arrays are not equal in the number of entries.

My goal is to have each array give me the bottom 90 records based on my criteria and sorted by date in ascending order (because the last dates are the most important, and I need these to line up so they can be view comparatively).

I've tried using...

CISMAprB07 = "SELECT TOP 90 [ISMpm]-[Apr] AS ISMAprBasis FROM ChartPrice where ISMpm >0 AND Apr >0 AND Date <= #2007/4/16# order by Date desc;"

... and it does work, although now my chart displays in reverse order (my closing data starts at the beginning - which is not good).

Any ideas?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-19 : 00:40:16
sounds like what you need is this:-

SELECT ISMAprBasis FROM
(
SELECT TOP 90 [ISMpm]-[Apr] AS ISMAprBasis FROM ChartPrice where ISMpm >0 AND Apr >0 AND Date <= #2007/4/16# order by Date desc
)t
ORDER BY Date asc


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -