continuous data comparison

rostien

New member
Local time
Today, 08:43
Joined
Sep 13, 2006
Messages
5
i have a table with fields: p,x,y,z,date
p being the common field with multiple values. for example:
p x y z date
100 2 2 2 oct 1 2011
100 3 3 3 oct 2 2011
100 3 4 5 oct 3 2011
100 4 4 4 oct 4 2011
how can i make a query to compare the data by the latest date to the previous date continuously as more data is added????
oct 4- oct3
p x y z
100 1 0 -1
oct 3- oct2
p x y z
100 0 1 2

PLEASE ACCESS GODS!!! I kneel in the shadow of your excellence.... HELP!!!
 
Hi..

can use this query..:



Code:
select  
           p, x, y, z, date, 
           x-(select last(x) from table_name where date<trz.date) as Xdifference, 
           y-(select last(y) from table_name where date<trz.date) as Ydifference, 
           z-(select last(z) from table_name where date<trz.date) as Zdifference

from table_name as trz
 
brilliant..
now how can i seperate the comparison so it will only compare the same p
 
brilliant..
now how can i seperate the comparison so it will only compare the same p

add this way.. ;)

Code:
select  
           p, x, y, z, date, 
           x-(select last(x) from table_name where date<trz.date[COLOR="Red"] and p=trz.p[/COLOR]) as Xdifference, 
           y-(select last(y) from table_name where date<trz.date[COLOR="Red"] and p=trz.p[/COLOR]) as Ydifference, 
           z-(select last(z) from table_name where date<trz.date [COLOR="red"]and p=trz.p[/COLOR]) as Zdifference

from table_name as trz
 
it works but if i change a date in the table the query doesn't update.. all the diff are now related to the 1st record?? do you know why??
 

Users who are viewing this thread

Back
Top Bottom