Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Posts
    4

    Unanswered: Sub total on columns in Sql*plus

    Hello There
    I am using sql*plus to write reports.

    I need to have sub totals on various columns as well as a grand totals at the end of the report. This is no problem when the subtotals are on simple columns.

    However when the value of column3 is equal to column1 divided by column2 the subtotal and grand total for column3 is incorrect. One cannot simply use the AVG function as it calculates it incorrectly even though the break clause is set on the correct field and the record.

    I cannot find any examples of how to do this in my reference books and would be grateful for any assistance.
    Thank you for your time. Regards Allan Godney

  2. #2
    Join Date
    Dec 2003
    Location
    Oklahoma, USA
    Posts
    354
    Here's a simple solution:

    SELECT column1, amount
    FROM <blah>
    UNION ALL
    SELECT 'Total' as column1, SUM( amount )
    FROM <blah>

    JoeB

  3. #3
    Join Date
    Jan 2004
    Location
    Scottsdale, AZ
    Posts
    106

    Post

    "Take Control!
    Make The Choice!
    Accept The Consequences!
    Deal With The Results! "

  4. #4
    Join Date
    Jun 2004
    Posts
    4
    Thanks for the input, I have had a look at your suggestions, but don't see how it will help me. I have attached a word document that further explains my problem. If you can point me in the right dirrection, I will be grateful. Thanks Allan Godney
    Attached Files Attached Files

Posting Permissions

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