Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

Aggregation Question

Edgar_10
Frequent Advisor

Aggregation Question

Hi,

Anyone know the syntax to generate a list of a count for records over a 24 day period.What I want to know is query the database and get records stored in table date field per hour.

Thanks in advance!
3 REPLIES
Yogeeraj_1
Honored Contributor

Re: Aggregation Question

hi,

can you try something like this one:

select mnumrows, to_char(mdate, 'dd/mm/yyyy hh24:mi')
from (
select count(*) mnumrows, trunc(trndat,'HH') mdate
from mytable
where trndat > sysdate-25
group by trunc(trndat,'HH')
)
/

hope this helps!
regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Yogeeraj_1
Honored Contributor

Re: Aggregation Question

hi again,

This is what i get on my test database (output has been limited to first 10 records)

yd@MYDB.MU> r
1 select mnumrows, to_char(mdate, 'dd/mm/yyyy hh24:mi')
2 from (
3 select count(*) mnumrows, trunc(trndat,'HH') mdate
4 from mytable
5 where trndat > sysdate-25
6 group by trunc(trndat,'HH'))
7* where rownum < 11

MNUMROWS TO_CHAR(MDATE,'D
__________ ________________
9 28/06/2003 14:00
46 28/06/2003 15:00
396 30/06/2003 08:00
403 30/06/2003 09:00
579 30/06/2003 10:00
414 30/06/2003 11:00
219 30/06/2003 12:00
604 30/06/2003 13:00
229 30/06/2003 14:00
230 30/06/2003 15:00

10 rows selected.

Elapsed: 00:00:00.16
yd@MYDB.MU>

Am sure other solutions do exits if you use Analytic Functions.

best regards
Yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Edgar_10
Frequent Advisor

Re: Aggregation Question

Hi Yogee!

Thanks man, You pointed me in the right directiorn!

Most appraciated!