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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Group resultset day by day

Re: Group resultset day by day

From: Jim Kennedy <jim>
Date: Thu, 14 Sep 2006 20:08:29 -0700
Message-ID: <jZOdnYXVIrr6hZfYnZ2dnUVZ_qudnZ2d@comcast.com>

"Juliano.net" <juliano.net_at_gmail.com> wrote in message news:1158263053.676554.30270_at_m73g2000cwd.googlegroups.com...
> Hi, I'm searching for a better way to do a procedure that SELECTs some
> data of a specific month and bring the resultset with the value grouped
> day by day.
>
> My tables:
>
> TBL_Activity
> ---------------------
> ID_Activity INT
> NM_Activity VARCHAR
>
> TBL_WorkingTime
> ---------------------
> ID_WorkingTime
> DT_DateTime
> NR_HoursSpent
> ID_Activity
>
> So, I need to get from all the activities (TBL_Activity) the sum of the
> NR_HoursSpent grouped by every month day.
>
> I need to have a resultset like this:
>
> ID_Activity | NM_Activity | Day 01 | Day 02 | Day 03 | and son on, up
> to the last month day | Day 31
>
> And for every Day, I get the sum of the NR_HoursSpent for that day.
>
> How can I do this?
>

select id_activity,nm_activity,to_char(dt_dateTime,'dd'),sum(nr_hoursspent) from ...
group by id_activity,nm_activity,to_char(dt_dateTime,'dd') order by nm_activity,3 ;

I'll let you figure out the join.
Jim Received on Thu Sep 14 2006 - 22:08:29 CDT

Original text of this message

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