sql sum (1 Viewer)

murray83

Games Collector
Local time
Today, 10:21
Joined
Mar 31, 2017
Messages
728
hi i have a little simple SQL code below

Code:
SELECT 

inv.Tag_Id  , inv.Description , inv.Owner_Id , inv.Sku_Id, inv. Qty_On_Hand, sk.Each_Value

FROM Inventory inv

INNER JOIN SKU sk 
ON inv.SKU_ID = sk.SKU_ID

WHERE
	
Location_Id   LIKE 'SUSPENSE' 

ORDER BY Pallet_Id DESC

which then generates the attached image( have blanked out bits cant show ) what i want is to sum like you would in excel the Qty_On_Hand * Each_Value

have searched here for sum and SQL and drew a blank also have tried looking at google and the quite good https://www.w3schools.com/sql/sql_count_avg_sum.asp

but all that seems to do is count how many records or sum the total of a whole column and i don't want that

any help would be great cheers
 

Attachments

  • ex1.png
    ex1.png
    4.3 KB · Views: 109

Gasman

Enthusiastic Amateur
Local time
Today, 10:21
Joined
Sep 21, 2011
Messages
14,038
Create an expression with that formula as an extra column and sum on that.
 

murray83

Games Collector
Local time
Today, 10:21
Joined
Mar 31, 2017
Messages
728
Create an expression with that formula as an extra column and sum on that.

that was a lot easier then i thought it would cheers :cool:

here is my new code for anybody intrested in same sort of thing

Code:
SELECT 

inv.Tag_Id  , inv.Description , inv.Owner_Id , inv.Sku_Id, inv.Qty_On_Hand, sk.Each_Value, (inv.Qty_On_Hand * sk.Each_Value) AS VALUE


FROM Inventory inv

INNER JOIN SKU sk 
ON inv.SKU_ID = sk.SKU_ID

WHERE
	
Location_Id   LIKE 'SUSPENSE' 

ORDER BY Pallet_Id DESC

and attached new screen shot showing additional column

:D:D:D
 

Attachments

  • ex2.png
    ex2.png
    4.4 KB · Views: 107

Users who are viewing this thread

Top Bottom