General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 4th, 2004, 08:15 PM
kakatooie kakatooie is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 1 kakatooie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy adding results of 2 queries

hi, im a total newb at oracle and SQL, and i am lost. my first question is (im sure more will come)

i want to run 2 queries that look something like this:
select sum( columnName )
from tableName
where bla bla bla;

and i want to add those 2 sums together, and i want to do it all in one solitary query.

can anybody please help me?
-ben

Reply With Quote
  #2  
Old March 5th, 2004, 09:07 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
I just ran a little test whose output should help you out:

Code:
mysql> select * from math;
+------------+------+------+
| id         | num  | num2 |
+------------+------+------+
| 0000000001 |    5 |   12 |
| 0000000002 |    5 |    3 |
| 0000000003 |    5 |   12 |
| 0000000004 |    5 |    3 |
| 0000000005 |    5 |   12 |
| 0000000006 |    7 |    3 |
| 0000000007 |    7 |   12 |
| 0000000008 |    7 |    3 |
| 0000000009 |    7 |   12 |
| 0000000010 |    7 |    3 |
+------------+------+------+
10 rows in set (0.00 sec)
 
mysql> select sum(num) from math;
+----------+
| sum(num) |
+----------+
|       60 |
+----------+
1 row in set (0.00 sec)
 
mysql> select sum(num2) from math;
+-----------+
| sum(num2) |
+-----------+
|        75 |
+-----------+
1 row in set (0.00 sec)
 
mysql> select sum(num) + sum(num2) from math;
+----------------------+
| sum(num) + sum(num2) |
+----------------------+
|                  135 |
+----------------------+
1 row in set (0.00 sec)
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > adding results of 2 queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT