Hi, I read your reply to a post entitled: Pl/sql problem.
I am trying to do something similar. I have already managed to print out the column name and the count of matches using UNION All.
Output is:
TEAM ASTON_VILLA_GAMES_LEFT
---------- ----------------------
Charlton 1
Liverpool 0
Arsenal 0
Chelsea 1
What I want to do now is to get the total for the 4 outputs. eg:
TEAM ASTON_VILLA_GAMES_LEFT
---------- ----------------------
Charlton 1
Liverpool 0
Arsenal 0
Chelsea 1
2
Any imediate help will be appreciated.
Many thanks,
** code **
BEGIN
select 'Charlton ' as Team, count(opponent) AS Aston_Villa_Games_Left
from charlton_games@charltonlink
where opponent = 'Aston Villa' AND match_date > sysdate
union all
select 'Liverpool ' as Team, count(opponent) AS Villa_Games_Left
from liverpool_games@liverpoollink
where opponent = 'Aston Villa' AND match_date > sysdate
union all
select 'Arsenal ' as Team, count(opponent) AS Villa_Games_Left
from arsenal_games@arsenallink
where opponent = 'Aston Villa' AND match_date > sysdate
union all
select 'Chelsea ' as Team, count(opponent) AS Villa_Games_Left
from chelsea_games@chelsealink
where opponent = 'Aston Villa' AND match_date > sysdate;
END
Ahmed
Quote:
Originally posted by andrewst
Yes, UNION ALL will give you a combined result like:
a 10
b 20
c 20
x 10
y 10
(where a,b,c are values of p1 and x,y are values of p2)
Is that what you want?
|