At 17:54 2013-03-12, Frank Cazabon <[email protected]> wrote:
[snip]
I would probably build the total cursor twice and then join them
based on the year in one being equal to the year in the other plus
or minus one.
There is no need to build the cursor twice. Do a
self-join. For example:
***** Start of Code Segment *****
create cursor sequential;
(;
theyear n(4) not null,;
thevalue n(9,2) not null;
)
insert into sequential;
(theyear,thevalue) values (2008,15000)
insert into sequential;
(theyear,thevalue) values (2009,17000)
insert into sequential;
(theyear,thevalue) values (2010,16500)
insert into sequential;
(theyear,thevalue) values (2011,17200)
insert into sequential;
(theyear,thevalue) values (2012,18900)
select;
thisyear.theyear as thisyear,thisyear.thevalue as current,;
lastyear.theyear as lastyear,lastyear.thevalue as previous;
from sequential as thisyear;
join sequential as lastyear on lastyear.theyear=thisyear.theyear-1;
order by thisyear.theyear
***** End of Code Segment *****
[snip]
Sincerely,
Gene Wirchenko
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/20130313162244.TWBZ10453.priv-edtnes27.telusplanet.net@edtncm02
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.