Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2010

    Cool Unanswered: Group by and Total

    I have a table with date, account, Active_flag (Yes/No) fields. I want to see how many Total number of accounts are active by the end of every week for a particular month. So here for a week 03.04.2012 i can have 250 active accounts, for 03.11.2012 i can have 300 active accounts, 03.18.2012 i can have 200 active accounts(which is less compared to previous week)
    Output i want:
    Weekend     Count
    03.04.2012     250
    03.11.2012     300
    03.18.2012     200
    This code below shows how many subscribers were activated every week Vs total number of active subscribers

    select Count(account), (DATE, 'IW') + 6 from table
    where Active_flag ='Y'
    group by (DATE, 'IW') + 6
    Output of my SQL. It gives counts only for that week but i want total counts till 03.04.2012, 03.11.2012 and so on...

    Weekend     Count
    03.04.2012      25
    03.11.2012      50
    03.18.2012       0

  2. #2
    Join Date
    Feb 2006
    Provided Answers: 1
    Can we see the exact query?
    I believe you would get an error would this sql because you need a to_char around(DATE, 'IW');
    select Count(account), (DATE, 'IW') + 6 from table where Active_flag ='Y' group by (DATE, 'IW') + 6
    Also some example data..

  3. #3
    Join Date
    May 2012
    dude use rollup function
    eg group by rollup(); and try ...

Posting Permissions

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