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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Query Question

Re: Query Question

From: Mladen Gogala <gogala_at_sbcglobal.net>
Date: Thu, 10 Aug 2006 21:58:52 -0400
Message-Id: <1155261532l.2701l.2l@medo.noip.com>

On 08/10/2006 04:08:01 PM, Hostetter, Jay M wrote:
> I know there has to be a simple way to do this, but my brain can't put
> it togther this afternoon. I have a parent table (accounts) and a child
> table (details). I am creating a view that ties the two tables
> together. I would like a column in this view that shows a summary of a
> column in the parent table - but I want this summary to be for each
> distinct parent record - not the child records.
>
> Here is my view:
>
> create view test_view
> (customer_name,
> amount,
> detail_item)
> as
> (select customer_name,
> sum(amount),
> detail_item
> from accounts a,
> details d
> where a.account_no=d.account_no
> group by customer_name;
>

How about this:

select customer_name,
 sum(amount) over (partition by customer_name) as cheating_total,  detail_item
 from accounts a,

        details d
 where a.account_no=d.account_no;

-- 
Mladen Gogala
http://www.mgogala.com

--
http://www.freelists.org/webpage/oracle-l
Received on Thu Aug 10 2006 - 20:58:52 CDT

Original text of this message

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