how to get overall total of several tables?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: how to get overall total of several tables?

  1. #1
    Join Date
    Apr 2001
    Location
    Congleton
    Posts
    258
    I do the following query and I want to get the overall total.
    select sum(nw1w2)||' CAA 97' totpas from caa97
    where apt='MAN'
    union all
    select sum(nw1w2)||' CAA 98' totpas from caa98
    where apt='MAN'
    union all
    select sum(nw1w2)||' CAA 99' totpas from caa99
    where apt='MAN'
    union all
    select sum(nw1w2)||' CAA 00' totpas from caa00
    where apt='MAN'
    union all
    select sum(nw1w2)||' CAA 01' totpas from caa01
    where apt='MAN'
    How do I do this?

  2. #2
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    SELECT sum(totpas) overall
    FROM
    (
    select ' CAA 97' tname, sum(nw1w2) totpas from caa97
    where apt='MAN'
    union all
    select ' CAA 98', sum(nw1w2) from caa98
    where apt='MAN'
    union all
    select ' CAA 99', sum(nw1w2) from caa99
    where apt='MAN'
    union all
    select ' CAA 00', sum(nw1w2) from caa00
    where apt='MAN'
    union all
    select ' CAA 01', sum(nw1w2) from caa01
    where apt='MAN'
    )

  3. #3
    Join Date
    Apr 2001
    Location
    Congleton
    Posts
    258
    Thanks. How can I get the total at the end of the results from each table?

  4. #4
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    I'd do that programmatically.
    Since 8.1.6. you can use analytic functions, but I do not know them at all.
    Perhaps somebody else ...

Posting Permissions

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



Click Here to Expand Forum to Full Width