Re: Summarize Table Info

From: Lun Wing San (Oracle) <"Lun>
Date: 1996/11/16
Message-ID: <328EBF22.24DB_at_qrcsun.qrc.org>#1/1


David Bruse wrote:
>
> Problem:
>
> I have a detail dollar table with dates. I need to create a table
> summarizing the last 3 calendar years by calendar year.
>
> Input:
>
> idnumber
> giftamount
> giftdate
>
> Desired Output:
>
> idnumber
> cy1996_amount
> cy1995_amount
> cy1994_amount
>
> I have tried a few ways. I am able to get the first calendar year by:
>
> create table cy1996 as
> select
> dollar.idnumber,
> sum(dollar.amount) "CY1996"
> from
> master,
> dollar
> where
> (master.idnumber = dollar.idnumber) and
> ((dollar.date >= '01-jan-96') and
> (dollar.date <= '31-dec-96'))
> group by
> dollar.idnumber
>
> How can I get the other two calendar years to work?
>

  You can use UNION operation. Alternatively, you can try to group by idnumber and the year. Hope that I do not misunderstand your question.

  Related Topics: SQL parsing, Tuning

---
Name   : Lun Wing San
Title  : Oracle Application Developer of Hong Kong Productivity Council
         Oracle Database Administrator and System Administrator of QRC
Phone  : (852)27885841
Received on Sat Nov 16 1996 - 00:00:00 CET

Original text of this message