If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Data by Week - DB2 v 6.2 on OS390

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-10-03, 18:44
antodomnic antodomnic is offline
Registered User
 
Join Date: Mar 2003
Posts: 69
Data by Week - DB2 v 6.2 on OS390

Hi,
Here is the scenario. I need to get the data from a table on a weekly basis. To be more clear, Actually we have a table which has 10000 records. The fields are,

rpt_no integer, rpttype integer , rpt_time timestamp .

We have records starting from year 2000. We need to get the count of rpt_type by weekly ( ie group by weekly basis). The date & time is stored in the rpt_time.

Is there a way we can achieve this through a query grouping by week.


Thanks,
Anto
Reply With Quote
  #2 (permalink)  
Old 12-11-03, 02:18
RKrick RKrick is offline
Registered User
 
Join Date: Feb 2002
Location: Germany
Posts: 141
Anto,

try the following query:
select rpttype, year, week, count(*)
from
(select rpttype, year(rpt_time) as year, week(rpt_time) as week
from your_table)
group by rpttype, year, week

HTH
__________________
Rodney Krick
Reply With Quote
  #3 (permalink)  
Old 12-11-03, 13:22
antodomnic antodomnic is offline
Registered User
 
Join Date: Mar 2003
Posts: 69
Re: Data by Week - DB2 v 6.2 on OS390

That works great. Thanks!


Quote:
Originally posted by antodomnic
Hi,
Here is the scenario. I need to get the data from a table on a weekly basis. To be more clear, Actually we have a table which has 10000 records. The fields are,

rpt_no integer, rpttype integer , rpt_time timestamp .

We have records starting from year 2000. We need to get the count of rpt_type by weekly ( ie group by weekly basis). The date & time is stored in the rpt_time.

Is there a way we can achieve this through a query grouping by week.


Thanks,
Anto
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On