I have a table and query that looks up previous records in. It works, but its really slow. Any suggestions to speed it up?
Table t_detail fields:
the records of interest are not adjacent rows, so a select is needed to get each one out.
How do I avoid needing the nested selects for each 'old' field I want to pull out?
The query to outputs something like
I use the next previous occurance of brand. (I can work out differences as required from this) Attached is the SQL.
Table t_detail fields:
Code:
id date stock qty brand
1 1/1/2008 1 1 A
2 1/2/2008 2 2 B
3 1/3/2008 3 3 A
How do I avoid needing the nested selects for each 'old' field I want to pull out?
The query to outputs something like
Code:
date brand stock qty old_stock old_qty
1/2/2008 B 2 2 - -
1/3/2008 A 3 3 1 1
Attachments
Last edited: