Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Posts
    15

    Unanswered: GROUP BY question

    Hi, I have the following query:
    select count(ship_to) ship_to_count,
    qsol_version,
    bill_to,
    trunc(reg_date) reg_date
    from reg_qsol
    where reg_date between '01-JAN-2003' and '31-DEC-2003'
    group by qsol_version,
    bill_to,
    reg_date

    which returns data like this:
    1 dealer 02001 2/17/2003
    1 dealer 02020 2/08/2003
    2 dealer 02001 1/30/2003

    What I would like to do is tak this result set and add up all the counts for
    each month of the year and still group by the qsol_version and bill_to so
    the final data looks something like this:
    23 dealer 02001 January
    11 dealer 02001 February
    .....
    21 dealer 02020 January etc.

    Is there any way to do this?

  2. #2
    Join Date
    Jul 2003
    Posts
    15
    Never mind. I figured it out.

  3. #3
    Join Date
    Jan 2004
    Location
    North Haven, CT
    Posts
    110

    Re: GROUP BY question

    Originally posted by brewerd
    Hi, I have the following query:
    select count(ship_to) ship_to_count,
    qsol_version,
    bill_to,
    trunc(reg_date) reg_date
    from reg_qsol
    where reg_date between '01-JAN-2003' and '31-DEC-2003'
    group by qsol_version,
    bill_to,
    reg_date

    which returns data like this:
    1 dealer 02001 2/17/2003
    1 dealer 02020 2/08/2003
    2 dealer 02001 1/30/2003

    What I would like to do is tak this result set and add up all the counts for
    each month of the year and still group by the qsol_version and bill_to so
    the final data looks something like this:
    23 dealer 02001 January
    11 dealer 02001 February
    .....
    21 dealer 02020 January etc.

    Is there any way to do this?
    select count(ship_to) ship_to_count,
    qsol_version,
    bill_to,
    to_char(trunc(reg_date),'MON-RR') reg_month
    from reg_qsol
    where reg_date between '01-JAN-2003' and '31-DEC-2003'
    group by qsol_version,
    bill_to,
    reg_date

  4. #4
    Join Date
    Jan 2004
    Location
    North Haven, CT
    Posts
    110

    Re: GROUP BY question

    Originally posted by lynden.zhang
    select count(ship_to) ship_to_count,
    qsol_version,
    bill_to,
    to_char(trunc(reg_date),'MON-RR') reg_month
    from reg_qsol
    where reg_date between '01-JAN-2003' and '31-DEC-2003'
    group by qsol_version,
    bill_to,
    reg_date
    select count(ship_to) ship_to_count,
    qsol_version,
    bill_to,
    to_char(trunc(reg_date),'MON-RR') reg_month
    from reg_qsol
    where reg_date between '01-JAN-2003' and '31-DEC-2003'
    group by qsol_version,
    bill_to,
    to_char(trunc(reg_date),'MON-RR')

Posting Permissions

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