need help very badly,i have two tables ppai and ctpl in sql server 2000:
PPAI
REGION PRODUCTION
CAR 1
CAR 1
CAR 1
R02 1
R02 1
CTPL
CAR 1
CAR 1
R02 1
R02 1
R02 1
R02 1
i would to compare the results of the two tables with the ff: output :
TYPE CAR R02
PPAI 3 2
CTPL 2 4
i have tried the ff: commands:
select
sum(case when reg_code = 'CAR' THEN PRODUCTION ELSE 0 END) AS CAR,
sum(case when reg_code = 'R02' THEN PRODUCTION ELSE 0 END) AS R02
FROM TBLQUERY UNION
SELECT
sum(case when reg_code = 'CAR' THEN PRODUCTION ELSE 0 END) AS CAR,
sum(case when reg_code = 'R02' THEN PRODUCTION ELSE 0 END) AS R02
FROM TBLQUERYTPL
and got the result : (missing PPAI CTPL TEXT SO I CAN IDENTIFY)
CAR R02
3 2
2 4
thanks in advance
PPAI
REGION PRODUCTION
CAR 1
CAR 1
CAR 1
R02 1
R02 1
CTPL
CAR 1
CAR 1
R02 1
R02 1
R02 1
R02 1
i would to compare the results of the two tables with the ff: output :
TYPE CAR R02
PPAI 3 2
CTPL 2 4
i have tried the ff: commands:
select
sum(case when reg_code = 'CAR' THEN PRODUCTION ELSE 0 END) AS CAR,
sum(case when reg_code = 'R02' THEN PRODUCTION ELSE 0 END) AS R02
FROM TBLQUERY UNION
SELECT
sum(case when reg_code = 'CAR' THEN PRODUCTION ELSE 0 END) AS CAR,
sum(case when reg_code = 'R02' THEN PRODUCTION ELSE 0 END) AS R02
FROM TBLQUERYTPL
and got the result : (missing PPAI CTPL TEXT SO I CAN IDENTIFY)
CAR R02
3 2
2 4
thanks in advance
Comment