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

Home -> Community -> Usenet -> c.d.o.tools -> Re: GROUP BY

Re: GROUP BY

From: Steve Cosner <stevec_at_zimmer.csufresno.edu>
Date: 1998/03/12
Message-ID: <6e93m0$6te@info.csufresno.edu>#1/1

In article <35080863.26336515_at_news.planetinternet.be>, Koen Serry <kaho_at_planetinternet.be> wrote:
>our table looks like this
>
>CREATE TABLE pagehits
> (host_id NUMBER(3) NOT NULL,
> url_id NUMBER(5) NOT NULL,
> datum DATE NOT NULL,
> aantal NUMBER(8) DEFAULT 0 )
>
>we're trying to select data grouped by "day"
>what's wrong with this
>
>'SELECT sum(aantal) FROM pagehits
> WHERE (datum = (SYSDATE-1))
> AND (hostid(host)=host_id)
> GROUP BY datum date(50) "dd/mon/yyyy"

Your GROUP BY column can only have one value since it is a condition in your where clause. Also, remember that time is included in your date and the SYSDATE values, so every value will be unique. And I don't know what "date(50)" means.

This might be closer to what you want:
  SELECT to_char(datum,'DD/MON/YYYY'),

          sum(aantal)
    FROM pagehits
    WHERE trunc(datum) = trunc(SYSDATE-1)     GROUP BY to_char(datum,'DD/MON/YYYY');

Steve Cosner Received on Thu Mar 12 1998 - 00:00:00 CST

Original text of this message

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