Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Posts
    69

    Unanswered: 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

  2. #2
    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

  3. #3
    Join Date
    Mar 2003
    Posts
    69

    Re: Data by Week - DB2 v 6.2 on OS390

    That works great. Thanks!


    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •