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 -> Re: Help with subquery

Re: Help with subquery

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Thu, 31 May 2001 20:41:28 +0200
Message-ID: <thd3um7jpe4mbe@beta-news.demon.nl>

<slundeen_at_sigatl.com> wrote in message
news:3b168a5f.22666192_at_news.easynews.com...
> I am having difficulty with what should be a simple query. I have two
> tables; Inventory Parts and Customer Orders. I want select the total
> Qty_On_Order for all parts. I assume I need to do a SELECT on the
> parts, with a subquery to sum the orders. Is there a better way?
>
> In my statement below, I cannot get it to return all item numbers
> unless I hard code the number. I cannot replace the '11508' with
> i.part_no.
>
> select i.part_no, i.description, ooo.Qty_On_Order from
> inventory_part_tab i,
> (select col.part_no,sum(col.Qty_On_Order) as Qty_On_Order from
> ifsapp.customer_order_line_tab col
> where col.part_no = '11108' group by col.part_no) ooo
> where i.part_no = ooo.part_no
>
> Make sense? Thanks.

The join should be between the table and the inline view (please don't call this a subquery, you are mixing up terminology -or Oracle already is of course), and not between *inside* the inline-view and the table. Remove the condition at it will work.

Hth,

Sybrand Bakker, Oracle DBA Received on Thu May 31 2001 - 13:41:28 CDT

Original text of this message

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