Re: sum of a column (development question)

  • From: "Don Seiler" <don@xxxxxxxxx>
  • To: lyallbarbour@xxxxxxxxxxxxxxx
  • Date: Tue, 11 Sep 2007 13:02:33 -0500

SELECT trunc(sysdate, 'YYYY'), SUM(ord_tot)
FROM ar_inv_hdr
GROUP BY trunc(sysdate, 'YYYY');

I think that'll do it.  Add in a WHERE clause after the FROM to limit
which time periods you want.

On 9/11/07, Lyall Barbour <lyallbarbour@xxxxxxxxxxxxxxx> 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
>
> --
> //www.freelists.org/webpage/oracle-l
>
>
>


-- 
Don Seiler
oracle: http://ora.seiler.us
ultimate: http://www.mufc.us
--
//www.freelists.org/webpage/oracle-l


Other related posts: