Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Sub total on columns in Sql*plus

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-14-04, 13:08
agodney agodney is offline
Registered User
 
Join Date: Jun 2004
Posts: 4
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
Reply With Quote
  #2 (permalink)  
Old 06-14-04, 15:08
joebednarz joebednarz is offline
PC Load Letter???
 
Join Date: Dec 2003
Location: Oklahoma, USA
Posts: 347
Here's a simple solution:

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

JoeB
Reply With Quote
  #3 (permalink)  
Old 06-14-04, 16:08
dbtoo2001 dbtoo2001 is offline
Registered User
 
Join Date: Jan 2004
Location: Scottsdale, AZ
Posts: 106
Post

__________________
"Take Control!
Make The Choice!
Accept The Consequences!
Deal With The Results! "
Reply With Quote
  #4 (permalink)  
Old 06-16-04, 11:17
agodney agodney is offline
Registered User
 
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
File Type: doc info.doc (23.0 KB, 13 views)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On