Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: help with a query
In article <lmmp5toill37i2dbj288k5ofm76tc3blps_at_4ax.com>,
See Message body for real address wrote:
>
> If I remember this correctly:
>
> at sqlplus prompt enter
> compute sum of sales on report
> break on Year_of_sale
>
> select to_char(date,'YYYY') Year_of_sale,sum(sales)
> group by to_char(date,'YYYY');
>
> javadrink_at_my-deja.com wrote:
>
> >Hi,
> >
> >Hope someone can help me with a query:
> >
> >I have the following table: table1, with 2 columns: sales, date
> >
> >what I want to do is:
> >
> >select and add the value of sales based on date:
> >
> >i.e.
> >result will be:
> >
> >(sales in year 1998), (sales in 1999), (sales in 2000), (total sale)
> >
> >Can I do it in ONE query?
> >
> >Thanks a lot!
> >
> >
> >
> >Sent via Deja.com
> >http://www.deja.com/
>
If you want it in other than sqlplus application:
select sum(decode(year_of_sale, '1998', sales, 0)) sales_1998, sum(decode(year_of_sale, '1999', sales, 0)) sales_1999, sum(decode(year_of_sale, '2000', sales, 0)) sales_2000, sum(sales) total_sales
>
Sent via Deja.com
http://www.deja.com/
Received on Thu Jan 11 2001 - 15:58:34 CST