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

Home -> Community -> Usenet -> c.d.o.server -> Re: Aggregate query

Re: Aggregate query

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Wed, 9 Feb 2000 09:56:27 +0100
Message-ID: <950086724.28060.0.pluto.d4ee154e@news.demon.nl>


Most likely your date column includes a time and you want a grouping by date, right?
So use trunc(start_time)
and reformulate your where clause in
start_time between trunc(to_date('&date1')) and to_date('&date2'||'23:59:59','HH24:MON:YYYY:HH24:MI:SS')

Hth,

Sybrand Bakker, Oracle DBA

Alexander T .Agung <alexander.agung_at_lippobank.co.id> wrote in message news:Dwko4.4363$15.35150_at_news...
> Hello all,
>
> I want to do a query to calculate aggregate using SUM function
>
> SELECT cdhsum.start_time, evsum.event, sum(evsum.sum_tot)
> FROM cdhsum, evsum
> WHERE cdsum.sumid = evsum.sumid AND
> (TO_CHAR(start_time, 'DD/MM/YY') BETWEEN '&date1' dan
> '&date2')
> GROUP BY start_time, event;
>
> result : 208 rows.
>
> but the query result was the same as i do the query without GROUP BY.
>
> SELECT cdhsum.start_time, evsum.event, evsum.sum_tot
> FROM cdhsum, evsum
> WHERE cdsum.sumid = evsum.sumid AND
> (TO_CHAR(start_time, 'DD/MM/YY') BETWEEN '&date1' dan
> '&date2');
>
> result : 208 rows
>
> What is wrong with the query ?????
>
> Thanks
>
> Alexander T. Agung
>
>
>
Received on Wed Feb 09 2000 - 02:56:27 CST

Original text of this message

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