G
Guest
Hi,
I hav a table with 3 columns
IndexId Dt Value
1 1/1/06 100
1 1/5/06 110
2 1/2/06 120
2 2/1/06 140
I have a query that brings a previous index value to the current value as..
IndexId Dt Value PrevVal
1 1/5/06 110 100
2 2/1/06 140 120
This query is to make return calculations
My query is as follows
SELECT Index.INDEXid, Index.DT, Index.VALUE, (Select Value From Index X where
Index.Indexid=X.Indexid and X.Dt=(Select max(Dt) from Index y
where y.Indexid=Index.Indexid and y.Dt<Index.Dt)) AS Prevval INTO RATES
FROM [Index];
but it is too slow.. only when i reduce the data size it works... I have
over 40.000 records and 8 different indexid's ..
Would anyone recommend an easier and faster way...
I hav a table with 3 columns
IndexId Dt Value
1 1/1/06 100
1 1/5/06 110
2 1/2/06 120
2 2/1/06 140
I have a query that brings a previous index value to the current value as..
IndexId Dt Value PrevVal
1 1/5/06 110 100
2 2/1/06 140 120
This query is to make return calculations
My query is as follows
SELECT Index.INDEXid, Index.DT, Index.VALUE, (Select Value From Index X where
Index.Indexid=X.Indexid and X.Dt=(Select max(Dt) from Index y
where y.Indexid=Index.Indexid and y.Dt<Index.Dt)) AS Prevval INTO RATES
FROM [Index];
but it is too slow.. only when i reduce the data size it works... I have
over 40.000 records and 8 different indexid's ..
Would anyone recommend an easier and faster way...