Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Next and Previous in MySQL

Status
Not open for further replies.

SBpsc

MIS
Dec 1, 2004
50
CA
Hi:
I am pretty new to MySQL. We are using MySQL 4.1.5 to write queries and incorporate them into Crystal Reports.

Is there a 'Next' or 'Previous' function in MySQL? I have not found anything. I have a table like the following:

Date1 | Date2 | Value
=================================
02/01/06 | 01/15/06 | 35
02/01/06 | 01/20/06 | 38
02/01/06 | 03/20/06 | 41
...

What I need is (using the second line as an example):
If (Date2 < Date1) Then MyAnswer = Previous(Value) = 35.

How do I write a query statement to get the previous value?

Can this be done using stored procedures?

Thanks in advance.
- SB


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top