× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



CREATE TABLE QTEMP/STEEMA
(PRODA CHAR (1 ), 
 AMTA DEC (5 , 0),
 PRODB CHAR (1 ), PRODC CHAR (1 )) 
INSERT INTO QTEMP/STEEMA VALUES('A', 1, 'B', 'C')
INSERT INTO QTEMP/STEEMA VALUES('D', 2, 'E', 'F')
INSERT INTO QTEMP/STEEMA VALUES('A', 3, 'D', 'C')

select proda as prod, amta from qtemp/steema 
union select prodb as prod, amta from qtemp/steema
union select prodc as prod, amta from qtemp/steema
PROD    AMTA
 A         1
 D         2
 A         3
 B         1
 E         2
 D         3
 C         1
 F         2
 C         3

with t1 as( 
select proda as prod, amta from qtemp/steema 
union select prodb as prod, amta from qtemp/steema 
union select prodc as prod, amta from qtemp/steema)
select prod, sum(amta) as total from t1 
group by prod 
order by prod 
....+....1....+....2....+....3....+....4....+..
PROD                                      TOTAL
 A                                            4
 B                                            1
 C                                            4
 D                                            5
 E                                            2
 F                                            2

Rob Berendt

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.