I have 2 tables containing the data for same items:

STORE1
-----------------------------
Id type items
-----------------------------
1 FOOD 10
2 FOOD 15
3 SOAP 20

STORE2
-----------------------------
Id type items
-----------------------------
1 FOOD 15
3 SOAP 10
4 PAPER 25
5 SOAP 12


What I am looking for is one single query that would return me TYPE-wise
total number of items from both the tables. UNION does not help me. I
want the result as:

Type count
-----------------------
FOOD 40 //10+15+15
SOAP 42 //20+10+12
PAPER 25

Thanks in advance,
-Satish

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
grouppgsql-general @
categoriespostgresql
postedJan 7, '11 at 10:25a
activeJul 12, '12 at 6:33p
posts3
users3
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase