I have 2 tables containing fields of :
Table 1 :
Employee ID Company
001 AAA
002 BBB
Table 2 :
Employee ID Period Basic Amount
001 199610 1000
002 199610 2000
001 199611 1200
002 199611 500
How can I try to create a cursor using SQL with end result of
Company 199610 199611
AAA 1000 1200
BBB 2000 500
.......
I have try the following :
SELECT table1.company, sum(table2.amount) ;
FROM table1 INNER JOIN table2 ;
ON table1.empid = table2.empid;
WHERE table2.period = '199610';
GROUP BY table1.company;
ORDER BY table1.company INTO CURSOR lc1
SELECT table1.company, sum(table2.amount) ;
FROM table1 INNER JOIN table2 ;
ON table1.empid = table2.empid;
WHERE table2.period = '199611';
GROUP BY table1.company;
ORDER BY tbale1.company INTO CURSOR lc2
SELECT * FROM lc1 INNER JOIN lc2 ON lc1.company=lc2.company INTO CURSOR lc3
PROBLEM is the cursor now is of structure :
Company_a
Basic_a
Company_b
Basic_b
Thanks in advance.
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement