exec SQL
declare stor_sls cursor for
select sdan8,
sdivd_year,
sum(sdaexp/100)
from f4211l9
where sdivd>=:j_start and sdivd<=:j_end and
sdlnty not in('T ', 'TN', '% ') and
sdmcu=:mcu group by sdan8, sdivd_year
order by sum(sdaexp) desc;
You will have to extract the sdivd_year from sdivd.
Paul
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Graves, Chuck
Sent: Wednesday, June 27, 2012 12:01 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: RPG/SQL
What type of select statement do I need to produce a data set containing:
Customer#
2011 sales
2012 sales
Generated from a file containing sales from several years.
I am using this statement:
exec SQL
declare stor_sls cursor for
select sdan8,
sum(sdaexp/100)
from f4211l9
where sdivd>=:j_start and sdivd<=:j_end and
sdlnty not in('T ', 'TN', '% ') and
sdmcu=:mcu group by sdan8
order by sum(sdaexp) desc;
This statement produces what I want for the given date range..i.e.
Customer#
2012 sales
but I need a separate field for the prior years sales
Do I declare a separate cursor for the prior year and then join the two???
Thanks in advance...
Chuck
[Rodda Paint Turns 80!] Chuck Graves
Director of Information Systems
Rodda Paint Co.<
http://www.roddapaint.com>
6107 N. Marine Drive
Portland, Oregon 97203
(503) 737-6042
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or
change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.