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: sum of a column (development question)

Re: sum of a column (development question)

From: Andrew Kerber <andrew.kerber_at_gmail.com>
Date: Tue, 11 Sep 2007 12:59:13 -0500
Message-ID: <ad3aa4c90709111059l224d2bf6y7923dc245907ec94@mail.gmail.com>


You are making a simple query awful hard. Try something like this:

select to_char(inv_date,'YYYY'), sum(ord_tot) "Invoiced Totals" from ar_inv_hdr
where inv_dt between to_date('01-jan-2006','dd-mon-yyyy') and sysdate group by to_char(inv_date,'YYYY')
order by to_char(inv_date,'YYYY')

On 9/11/07, Lyall Barbour <lyallbarbour_at_sanfranmail.com> wrote:
>
> Hi again,
> Development question. User wants the sum of all the purchase orders
> for this year and last year. I'm trying to get it in the same select
> statement. I want something like this, but don't know how to get it.
>
> select sum(ord_tot) "TY Invoiced Totals",
> sum(ord_tot) "LY Invoiced Totals"
> from ar_inv_hdr
> where inv_dt between trunc(sysdate, 'YYYY') and sysdate
> and inv_dt between trunc(sysdate, 'YYYY')-1 and trunc(sysdate,
> 'YYYY')-365
>
> This, obviously, doesn't do what i want, but it's where i've gotten to so
> far. Do i need to select from the same table twice?
>
> Thanks,
> Lyall
>
> --
> We've Got Your Name @ www.mail.com!!!
> Get a FREE E-mail Account Today - Choose From 100+ Domains
>
> --
> http://www.freelists.org/webpage/oracle-l
>
>
>

-- 
Andrew W. Kerber

'If at first you dont succeed, dont take up skydiving.'

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Sep 11 2007 - 12:59:13 CDT

Original text of this message

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