Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQl Math

Author  Topic 

dgamma3
Starting Member

2 Posts

Posted - 2010-08-27 : 23:06:03
Hello how would you add two SQL results together, providing the columns are integers or floats

for example, how do i add this:
SELECT BulkPacksOrdered
FROM products

to this:
SELECT BulkPacks
FROM products


I know i can do this:

SELECT (BulkPacks + BulkPacksOrdered) as TotalBulkpacks
FROM products


But i need to know how to add two different SQL queries together

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-28 : 00:02:25
Please show us sample data and expected output.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-28 : 00:42:19
whatever you've shown in possible in sql. you'll get result as sum of two quantities in each row. Didnt understand what you meant by adding tow queries? can you elaborate?



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

dgamma3
Starting Member

2 Posts

Posted - 2010-08-28 : 08:36:56
Dont worry guys I've figured it out, but thanks for the interested.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-08-31 : 06:30:17
quote:
Originally posted by dgamma3

Dont worry guys I've figured it out, but thanks for the interested.


Have you used union or union all ?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -