Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SUM values in SQL Query

$
0
0

Good Day,

We are using an SQL query to generate data for Pallet Labels. Each Lot Number will have a quantity associated with it. What I need to do is somehow create a Total Count Column in the statement to tally all of the Quantity fields. Below is the current SQL query statement:

select
ble.id as PrintID,
head.Code,
head.U_WhsCode,
head.U_BinCode,
l1.U_ItemCode,
l1.U_Description,
l1.U_DistNumber as Lot1, l1.U_Quantity as Quantity1,
l2.U_DistNumber as Lot2, l2.U_Quantity as Quantity2,
l3.U_DistNumber as Lot3, l3.U_Quantity as Quantity3,
l4.U_DistNumber as Lot4, l4.U_Quantity as Quantity4,
l5.U_DistNumber as Lot5, l5.U_Quantity as Quantity5,
l6.U_DistNumber as Lot6, l6.U_Quantity as Quantity6,
l7.U_DistNumber as Lot7, l7.U_Quantity as Quantity7,
l8.U_DistNumber as Lot8, l8.U_Quantity as Quantity8,
l9.U_DistNumber as Lot9, l9.U_Quantity as Quantity9,
...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>