Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Oracle SQL query help

Oracle SQL query help

From: Dave Martin <demonick_at_hotmail.com>
Date: 2000/02/15
Message-ID: <vokq4.8704$Zp1.255298@newsread1.prod.itd.earthlink.net>#1/1

Platform: Oracle 805 on Sun Solaris

Items involved...
2 tables: PHierarchyTbl and SalesTbl (not my actual database)

PHierarchyTbl (contains Product Hierarchy)

ProdID       PCategID        Name                               ...(more
columns)
10                                        Golf Equipment
234            10                     Deluxe Golf Club Set
235            10                     Standard Golf Tees
20                                        Tennis Equipment

...

PEventTbl (contains Product Events: Sale, Return, Purchase, etc.)

ProdID     ProductEvent          ...(more columns)
234           Sale
234           Sale
234           Return
235           Sale

...

The inital query...
select distinct(a.PCategID) "Product Category ID",

       count(b.ProductEvent) "Units Sold" from PHierarchyTbl a, PEventTbl b
where a.ProdID = b.ProdID(+)
and b.ProductEvent='Sale'
group by a.PCategID

Output...

Product Category ID            Units Sold
10                                           3
20                                           6

....

The problem...
The purpose of the above query (which works fine) is to get a summary of the items sold at the Category level. However I need the name to be on the output report, not the CategoryID.

The Desired Result...

Product Category ID            Units Sold
Golf Equipment                     3
Tenis Equipment                   6

....

Any suggestions will be much appreciated. Please copy me at dmarajh_at_yahoo.com.
Thanks a bunch.

Dave Received on Tue Feb 15 2000 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US