Results 1 to 3 of 3

Thread: Total

  1. #1
    Join Date
    Jul 2010
    Posts
    6

    Unanswered: Total

    select a_b,
    sum(value)

    from
    table1

    where
    date = 20101112
    group_by
    a_b

    I get 2 rows as results like

    a 125436.00
    b 874563.00

    I want to create another row with the totaling a and b showing like

    a 125436.00
    b 874563.00
    tot 998019.00

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    If you are using pure SQL and not some reporting tool, you will need to do a UNION ALL (two different queries).
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Try GROUP BY ROLLUP (a_b)

Posting Permissions

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