Click here to Skip to main content
15,886,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
(select sum(Amount)
from  Receipt_NoteDetalisTBL
group by Product_Id
HAVING Product_Id = 1
)
\
(
select sum(Quantity)
from  Receipt_NoteDetalisTBL
group by Product_Id
HAVING Product_Id = 1
)



For Excample
result 1 = 100
result 2 = 200


result 1 / 2 =0.5
Posted
Updated 10-Aug-15 19:04pm
v3

Declare the variable:
EXAMPLE:

SQL
SELECT SUM(Amount) / SUM(Quantity) AS Result
FROM  Receipt_NoteDetalisTBL
GROUP BY Product_Id
HAVING Product_Id = 1


Hope it helps :)
 
Share this answer
 
v2
Comments
Member 11280947 11-Aug-15 1:06am    
How Can use this code with 2 statement
Sanket Saxena 11-Aug-15 1:23am    
See the updated solution. Same as Zang Suggested.

For showing the division of sum(Amount) and sum(Quantity) you can just write it in the SELECT clause. Something like:


SQL
SELECT sum(Amount) / sum(Quantity) AS Result
FROM  Receipt_NoteDetalisTBL
GROUP BY Product_Id
HAVING Product_Id = 1
 
Share this answer
 
Comments
Member 11280947 11-Aug-15 1:28am    
Thank You
Shmuel Zang 11-Aug-15 1:43am    
You welcome.

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