Click here to Skip to main content
15,885,036 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

I want solution for fallowing SQL

SQL
SELECT [INWARD RG].MD
	,[INWARD RG].UNIT
	,[INWARD RG].STOCK
	,[INWARD RG].[SumOfConverted Qty]
	,[INWARD RG].SumOfPurchase1
	,[INWARD RG].[SumOfSite Return Qty]
FROM [INWARD RG];


in INWARD RG Query i want STOCk as a Sum of [SumOfConverted Qty]+SumOfPurchase1+[SumOfSite Return Qty]

Please tell the solution in SQL from as above
Please help me...
Posted
Updated 5-Jan-15 18:03pm
v2
Comments
ArunRajendra 6-Jan-15 4:28am    
Do you want sum for each row or for all the rows?

What kind of database is this? The syntax looks strange to me. If I were doing this I would simply do something like this:

SQL
SELECT SUM(column1) as Total1, SUM(column2) as Total2, SUM(column3) as Total3, 
SUM(column1 + column 2 + column3) as GrandTotal

FROM MyTable
 
Share this answer
 
It should be simple as below

SQL
SELECT [INWARD RG].MD
    ,[INWARD RG].UNIT
    ,[SumOfConverted Qty]+SumOfPurchase1+[SumOfSite Return Qty] As STOCK
    ,[INWARD RG].[SumOfConverted Qty]
    ,[INWARD RG].SumOfPurchase1
    ,[INWARD RG].[SumOfSite Return Qty]
FROM [INWARD RG];
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900