I have a query that is working but I figure I could enlist some help to make it more efficient. However before I show the query I would like to get a few answer on how others would do this.
What the query is supposed to do is to select data from a table, however some of the data is calculated within the SELECT
statement. One of those calculations is the retreival of data from the next row. For example, I select a date from the current record, but I also want to know the next row's date as well.
Sample data:
======================= date | comment ======================= 2013-01-01 | comment 2013-03-03 | comment
Desired output:
====================================== date | leadDate | comment ====================================== 2013-01-01 | 2013-03-03 | comment 2013-03-03 | null | comment
Right now I am using a stored function
and a cursor
to get this info and I tried using a LEFT JOIN
which messed up my variables I am using.
I just wanted to get input from others on how they would do this.