Re: Record lag functionality in MySQL?

2004-03-31 Thread John Thorpe
If I'm reading this correctly, a self-join might
work if you have a primary key defined:
select
 t1.a as a1
,t1.b as b1
,t1.c as c1
,t2.a as d1
from
 thetable as t1
,thetable as t2
where
t2.primaryid = t1.primaryid+1
John

David L. Van Brunt, Ph.D. wrote:
I have a table of data...

A1 B1 C1
A2 B2 C2
And I¹d like to make a query where I ³lag² a value, grabbing a value from
the next row of the table. Most stat packages have a lag function, but I
can¹t find this in MySQL. The end result would look like:
A1 B1 C1 D1 (where ³D1² would equal A2 from above)

Any suggestions?



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Record lag functionality in MySQL?

2004-03-30 Thread David L. Van Brunt, Ph.D.
I have a table of data...


A1 B1 C1
A2 B2 C2

And I¹d like to make a query where I ³lag² a value, grabbing a value from
the next row of the table. Most stat packages have a lag function, but I
can¹t find this in MySQL. The end result would look like:

A1 B1 C1 D1 (where ³D1² would equal A2 from above)

Any suggestions?

-- 
David L. Van Brunt, Ph.D.
Outlier Consulting  Development
mailto: [EMAIL PROTECTED]