MySQL Forums
Forum List  »  Newbie

group select union all
Posted by: akel arenas
Date: August 11, 2004 12:54AM

hi all !!

is it posible to group the result of the union query? i have two queries the ive union. but i want to add the total result if have the same street

example

SELECT count(c.struc_key) as total, a.street
FROM address a, client_info c, struc_addrs s
WHERE a.struc_type = '002' and
c.sector = '001' AND
c.branch = '001' and
a.addrs_key = s.addrs_key and
s.struc_key = c.struc_key and
c.status_type = '002'
GRoup by a.street, a.brgy_village, a.city_muni, a.province, a.region
union all
SELECT count(c.struc_key) as total, a.street,
FROM address a, client_info c, struc_addrs s
WHERE a.struc_type = '002' and
c.sector = '001' AND
c.branch = '001' and
a.addrs_key = s.addrs_key and
s.struc_key = c.struc_key and
c.status_type in('001','003','004') and
c.sales_officer = '0419'
GRoup by a.street, a.brgy_village, a.city_muni, a.province, a.region
ORDER BY a.street;

the result of the query are as follows :

total street
1 4
1 4

but the result shld be
total street
2 4

so cud i group the union queries ??
tnx a lot

Options: ReplyQuote


Subject
Written By
Posted
group select union all
August 11, 2004 12:54AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.