|
First off, Since you are not doing a LEFT JOIN, there's no need
to use the COALESCE function unless SSVNDCHS has null values in
those fields.
I actually prefer this method since you are doing a regular
join.
Exec SQL
Select :CurYYYYMM,
Coalesce(Sum(s.VCSALS), 0),
Coalesce(Sum(s.VCCGSL), 0),
Coalesce(Sum(s.VCGMGN), 0),
0,
Coalesce(Sum(s.VCCASH), 0),
Coalesce(Sum(s.VCUNSH), 0),
Coalesce(Sum(s.VCCDAM), 0),
Coalesce(Sum(s.VCNMGN), 0),
0
Into :CYT
From SSVNDCHS s Join DMCUSMST c
On s.VCCSNR = c.CUSNR
and s.VCYYMM = :CurYYYYMM
and c.SLSNR = :srslnr;
If you put your record selections in the "ON" clause, you'll
select records from the two files before the join occurs so
there are less records being joined. FYI, I have tested this
with statements of my own. A webpage went
from 3 minutes to load to just 1 second by using this method.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.