Table Structure
Item, Group, Min Qty, Price
A, 1, 10, 1.00
A, 2, 10, 0.75
B, 1, 20, 0.90
C, 3, 5, 5.00
Sql query I am running currently which works for all the groups into 1 column, I'm trying to work out how I add a column for each group and only put in the values from that group only.
SELECT [Item],
STUFF((
SELECT ', ' + CAST([Min Qty] AS VARCHAR(MAX)) + ':' + CAST([Price] AS VARCHAR(MAX) + ';')
FROM [Table] WHERE ([Item No_] = Results.[Item] and [Minimum Qty] > '1')
FOR XML PATH(''),TYPE
).value('.','VARCHAR(MAX)')
,1,2,'') as Values
FROM [Table] Results
GROUP BY [Item]
Current output
Item, Values
A, 10:0.75; 10:1.00;
B, 20:0.90;
C, 5:5.00;
Required output
Item, Group 1, Group 2, Group 3
A, 10:1.00; 10:0.75;
B, 20:0.90;
C, 5:5.00;
Thank you for input
Edit from below
We don't know all the column names as they will be added by other users to the system, so needs to auto add the columns also should be grouping all entries for that group/item into 1 column as I'm trying to produce an output file.
Table information
Item, Group, Min Qty, Price
A, 1, 10, 1.00
A, 2, 10, 0.75
B, 1, 20, 0.90
C, 3, 5, 5.00
A, 1, 20, 0.50
Item, Group 1, Group 2, Group 3
A, 10:1.00;20:0.50; 10:0.75;
B, 20:0.90;
C, 5:5.00;
declare #t table (Item Varchar(2),Groups Varchar(2),MInqty varchar(10),Price Money)
insert into #t (Item,Groups,MInqty,Price)values
('A,','1,',10,1.00),
('A,','2,',10,0.75),
('B,','1,',20,0.90),
('C,','3,',5,5.00)
select Item,[1,] AS [Groups 1],[2,] AS [Groups 2],[3,] AS [Groups 3]
from (
select Item,Groups,MInqty +':'+ CAST(price AS VARCHAR) + ';' As GRP from #t)P
PIVOT (MIN(GRP) FOR GROUPS IN ([1,],[2,],[3,]))PVT
Remodified answer check
Select Item,[1] AS [Groups 1],[2] AS [Groups 2],[3] AS [Groups 3] from (
Select P.Item,MIN(R)G,P.Value from (
SELECT [Item],SUBSTRING(Groups,0,CHARINDEX(',',Groups))R,
STUFF((
SELECT ', ' + CAST([MInqty] AS VARCHAR(MAX)) + ':' + CAST([Price] AS VARCHAR(MAX) )+';'As Grp
FROM #t WHERE ([Item] = Results.[Item] and [MInqty] > '1')
FOR XML PATH(''),TYPE
).value('.','VARCHAR(MAX)')
,1,2,'') as Value
FROM #t Results
GROUP BY Groups,Item)P
GROUP BY P.Item,p.Value)PP
PIVOT (MIN(Value)FOR G IN ([1],[2],[3]) )PVT
Related
I am trying to figure out an efficient way to select the previous order item for each order item in a current order.
For example each order has a set of order items, i.e. the amount of an article/product that was ordered. For a particular customer, this would result in an order history as illustrated below:
I would like to find the "previous" orderitem for each orderitem in a particular order, i.e. the most recent orderitem for the same customer and article product preceding the order in question. These are highlighted above. Note that the previous orderitem may not be from the previous order of that customer.
Selecting it for a particular orderitem in an order with :datetime for :customerID and :articleID could be done like this:
select top(1) *
from orderitem
join order on order.orderid = orderitem.orderid
where order.customerID = :customerID
and order.datetime < :datetime
and orderitem.articleID = :articleID
order by order.datetime desc
However, is there an efficient way rather than looping or using a sub-select to select all previous orderitems for a given order with a single select or some type of join?
Your description of your desired outcome isn't quite clear. This sounds like you want a pivot table for the customer with the most recent order on the left. Here's an example of using PIVOT to accomplish the desired output. It only has order dates, if you want order numbers, that can be added in the column names.
--Create tables for test data.
CREATE TABLE order_hdr (
order_number int
, order_date date
, customer_id int
);
CREATE TABLE order_lines (
order_number int
, line_number int
, quantity int
, item_id nvarchar(50)
);
--Populate test data.
INSERT INTO order_hdr (order_number, order_date, customer_id)
VALUES (111, '1/1/2022', 12345)
, (112, '1/2/2022', 45678)
, (113, '1/2/2022', 87964)
, (114, '1/3/2022', 12345)
, (115, '1/3/2022', 45678)
, (116, '1/3/2022', 87964)
, (117, '1/9/2022', 12345)
, (118, '1/9/2022', 45678)
, (119, '1/9/2022', 87964)
;
INSERT INTO order_lines (order_number, line_number, quantity, item_id)
VALUES (111, 1, 4, 'Article A')
, (111, 2, 2, 'Article B')
, (111, 3, 3, 'Article C')
, (111, 4, 1, 'Article D')
, (112, 1, 1, 'Article B')
, (112, 2, 1, 'Article C')
, (112, 3, 1, 'Article D')
, (113, 1, 11, 'Article B')
, (113, 2, 9, 'Article C')
, (113, 3, 8, 'Article D')
, (114, 1, 4, 'Article C')
, (114, 2, 6, 'Article D')
, (115, 1, 77, 'Article A')
, (115, 2, 22, 'Article B')
;
--Variables for filtering data.
DECLARE #CustID int = 12345;
DECLARE #ReportDate date = '2/1/2022';
DECLARE #ItemID nvarchar(50) = 'Article A'; --Not used.
--Create a variable to hold the string of dates.
DECLARE #dates nvarchar(max);
--Get last 5 distinct order dates.
SET #dates = STUFF((
SELECT ',"' + CAST(order_date as nvarchar) + '"'
FROM (
SELECT DISTINCT TOP (5) order_date
FROM order_hdr
WHERE customer_id = #CustID
ORDER BY order_date DESC
) as prelim
FOR XML PATH('')
),1,1,'');
--For debugging, show the string of dates.
PRINT 'Date string contents: ' + #dates;
--For debugging/testing, here is a static query using PIVOT
PRINT 'Test Query using Static Order Dates:';
SELECT item_id, "1/3/2022", "1/2/2022"
FROM (
SELECT
oh.order_date
, ol.item_id
, ol.quantity
FROM order_hdr as oh
INNER JOIN order_lines as ol
ON ol.order_number = oh.order_number
WHERE oh.customer_id = #CustID
) as st
PIVOT
(
SUM(quantity)
FOR order_date IN ("1/3/2022", "1/2/2022")
) as pt
;
--Now create a text variable to hold the dynamic SQL. We will substitue the place holders for the order dates or order numbers.
DECLARE #sqlText nvarchar(max) = N'
SELECT item_id, {{0}}
FROM (
SELECT
oh.order_date
, ol.item_id
, ol.quantity
FROM order_hdr as oh
INNER JOIN order_lines as ol
ON ol.order_number = oh.order_number
WHERE oh.customer_id = {{1}}
) as st
PIVOT
(
SUM(quantity)
FOR order_date IN ({{0}})
) as pt
;
';
--Replace the placeholders with the date string;
SET #sqlText = REPLACE(#sqlText, '{{0}}', #dates);
--Replace the placeholders with the date string;
SET #sqlText = REPLACE(#sqlText, '{{1}}', CAST(#CustID as nvarchar));
--Show query for debugging.
PRINT 'The dynamic query: ' + CHAR(13) + #sqlText;
--Execute the dynamic sql.
PRINT 'Final Query using Dynamic Order Dates:';
EXEC (#sqlText);
Test Query using Static Order Dates:
item_id
1/3/2022
1/2/2022
Article A
null
null
Article B
null
null
Article C
4
null
Article D
6
null
Date string contents: "2022-01-09","2022-01-03","2022-01-01"
The dynamic query:
SELECT item_id, "2022-01-09","2022-01-03","2022-01-01"
FROM (
SELECT
oh.order_date
, ol.item_id
, ol.quantity
FROM order_hdr as oh
INNER JOIN order_lines as ol
ON ol.order_number = oh.order_number
WHERE oh.customer_id = 12345
) as st
PIVOT
(
SUM(quantity)
FOR order_date IN ("2022-01-09","2022-01-03","2022-01-01")
) as pt
;
Final Query using Dynamic Order Dates:
item_id
2022-01-09
2022-01-03
2022-01-01
Article A
null
null
4
Article B
null
null
2
Article C
null
4
3
Article D
null
6
1
fiddle
I have a table like this:
ID Type Score
-------------------
5 1 100
8 1 200
3 1 300
8 2 100
3 2 200
5 2 300
How do I sort them by descending score (to give them a ranking for that Type) and then create a table which a column for each Type where the ID's positions are shown such as:
ID Type1 Type2
--------------------
3 1st 2nd
5 3rd 1st
8 2nd 3rd
So far I am able able to do this by explicitly declaring the Type number such as:
SELECT ROW_NUMBER() OVER(ORDER BY Score DESC) AS Rank, ID
FROM Table
WHERE Type = 1
This returns a rank for each ID when Type is 1.
How do I join this together with the same result when Type is 2? And how do I do this for any number of types?
There are a number of ways to tackled this. My choice would be to use conditional aggregation. Here is how this might look. If you need a dynamic number of types that can be accomplished also but is a little trickier.
declare #Something table
(
ID int
, Type int
, Score int
)
;
insert #Something values
(5, 1, 100)
, (8, 1, 200)
, (3, 1, 300)
, (8, 2, 100)
, (3, 2, 200)
, (5, 2, 300)
;
with SortedValues as
(
select *
, RowNum = ROW_NUMBER() over (partition by Type order by Score)
from #Something
)
select ID
, Type1 = max(case when Type = 1 then RowNum end)
, Type2 = max(case when Type = 2 then RowNum end)
from SortedValues
group by ID
order by ID
;
-- EDIT --
I realized you said you need to have this work for any number of Types. Most people around SO like to ue a dynamic pivot. I personally find the syntax for pivot to be very obtuse. I prefer to build a dynamic version of conditional aggregation for this type of thing. Here is how you can use dynamic sql to generate the results for any number of Types.
Note I had to switch to using a temp table because a table variable would not be available in the scope of the dynamic sql unless it is declared inside the dynamic sql.
if OBJECT_ID('tempdb..#Something') is not null
drop table #Something
create table #Something
(
ID int
, Type int
, Score int
)
;
insert #Something values
(5, 1, 100)
, (8, 1, 200)
, (3, 1, 300)
, (8, 2, 100)
, (3, 2, 200)
, (5, 2, 300)
;
declare #StaticPortion nvarchar(2000) =
'with SortedValues as
(
select *, ROW_NUMBER() over(partition by Type order by Score) as RowNum
from #Something
)
select ID';
declare #DynamicPortion nvarchar(max) = '';
with E1(N) AS (select 1 from (values (1),(1),(1),(1),(1),(1),(1),(1),(1),(1))dt(n)),
E2(N) AS (SELECT 1 FROM E1 a, E1 b), --10E+2 or 100 rows
cteTally(N) AS
(
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM E2
)
select #DynamicPortion = #DynamicPortion +
', MAX(Case when Type = ' + CAST(N as varchar(6)) + ' then RowNum end) as Type' + CAST(N as varchar(6)) + CHAR(10)
from cteTally t
where t.N <=
(
select Count(distinct Type)
from #Something
)
declare #FinalStaticPortion nvarchar(2000) = ' from SortedValues
group by ID
order by ID';
select #StaticPortion + #DynamicPortion + #FinalStaticPortion
declare #SqlToExecute nvarchar(max) = #StaticPortion + #DynamicPortion + #FinalStaticPortion;
select #SqlToExecute
exec sp_executesql #SqlToExecute
I am using a database that consist of answers to customer questionnaires. My problem is that while the customers has been asked several questions each, the number and specific questions vary and each question has its own record. So each questionnaire has three questions.
I have grouped the question types and want one record for each questionnaire with all the answers.
If qnumber [1,2,3],[4,5,6],[7,8,9] are the same and the info is like this
ID,qnumber,avalue
1,1,4
1,4,5
1,7,6
2,2,5
2,5,6
2,8,7
3,3,7
3,6,8
3,9,9
I want to construct the query so a get a result like this:
ID,q1,q2,q3
1,4,5,6
2,5,6,7
3,6,7,8
Is that even possible?
Try this
;With cte(ID,qnumber,avalue )
AS
(
SELECT 1,1,4 UNION ALL
SELECT 1,4,5 UNION ALL
SELECT 1,7,6 UNION ALL
SELECT 2,2,5 UNION ALL
SELECT 2,5,6 UNION ALL
SELECT 2,8,7 UNION ALL
SELECT 3,3,7 UNION ALL
SELECT 3,6,8 UNION ALL
SELECT 3,9,9
)
SELECT Cstring AS CombinedValue
,SUBSTRING(Cstring, 0, CHARINDEX(',', Cstring)) AS ID
,SUBSTRING(Cstring, CHARINDEX(',', Cstring) + 1, CHARINDEX(',', Cstring) - 1) AS Q1
,SUBSTRING(Cstring, CHARINDEX(',', Cstring) + 5, CHARINDEX(',', Cstring) - 1) AS Q2
,SUBSTRING(Cstring, CHARINDEX(',', Cstring) + 9, CHARINDEX(',', Cstring) - 1) AS Q2
FROM (
SELECT DISTINCT STUFF((
SELECT ',' + CAST(qnumber AS VARCHAR) + ',' + CAST(avalue AS VARCHAR)
FROM cte i
WHERE i.ID = o.ID
FOR XML PATH('')
), 1, 1, '') AS Cstring
FROM cte o
) DT
Result
CombinedValue ID Q1 Q2 Q2
------------------------------
1,4,4,5,7,6 1 4 5 6
2,5,5,6,8,7 2 5 6 7
3,7,6,8,9,9 3 7 8 9
CREATE TABLE #Temp
(
ID INT,
qnumber INT,
avalue INT
)
INSERT #Temp
VALUES
(1,1,4),
(1,4,5),
(1,7,6),
(2,2,5),
(2,5,6),
(2,8,7),
(3,3,7),
(3,6,8),
(3,9,9)
SELECT ID, [1] AS q1, [2] AS q2, [3] AS q3
FROM (
SELECT ID, [1], [2], [3]
FROM (
SELECT ID,
CASE WHEN qnumber IN (1, 2, 3) THEN 1
WHEN qnumber IN (4, 5, 6) THEN 2
WHEN qnumber IN (7, 8, 9) THEN 3
END AS qnumber,
avalue
FROM #Temp) AS SourceTable
PIVOT
(AVG(avalue)
FOR qnumber IN ([1], [2], [3])) AS PivotTable
) t
DROP TABLE #Temp
I have multiple rows of order data which i need to consolidate in one row per part.
An example is as follows:
OrderNum PartNum Qty
-------------------------------
1 24 2
2 25 10
3 24 5
4 24 10
This then needs to be consolidated into:
OrderNum PartNum Qty
-------------------------------
1, 3, 4 24 17
2 25 10
Does anybody have any ideas how I can do this?
I have had a look around online but cannot find a solution to this use case.
Many thanks in advance,
Try this
SELECT STUFF((SELECT ',' + CAST(OrderNum AS VARCHAR(4))
FROM mytable AS s
WHERE s.PartNum = t.PartNum
FOR XML PATH('')), 1, 1, '') AS OrderNum
PartNum, SUM(Qty)
FROM mytable AS t
GROUP BY PartNum
This can be done by grouping on PartNum, sum the quantities with SUM() and concatenating strings using FOR XML PATH('') in a correlated subquery. Using FOR XML PATH('') to concatenate string is explained in this answer on SO.
DECLARE #t TABLE(OrderNum INT, PartNum INT, Qty INT);
INSERT INTO #t(OrderNum,PartNum,Qty)
VALUES(1,24,2),(2,25,10),(3,24,5),(4,24,10);
SELECT
OrderNum=STUFF((
SELECT
','+CAST(i.OrderNum AS VARCHAR)
FROM
#t AS i
WHERE
i.PartNum=o.PartNum
FOR XML
PATH(''), TYPE
).value('.[1]','VARCHAR(MAX)'),1,1,''),
o.PartNum,
Qty=SUM(o.Qty)
FROM
#t AS o
GROUP BY
o.PartNum;
Result:
OrderNum | PartNum | Qty
------------------------
1,3,4 | 24 | 17
2 | 25 | 10
SQL Server 2016 added the STRING_AGG function.
In your case, you could write
select STRING_ACC(OrderId,','),PartNum, Sum(Qty)
from MyTable
Group by PartNum
For earlier versions you'd have to use one of the techniques described by Aaron Bertrand in Grouped Concatenation in SQL Server. The fastest is to use a SQLCLR method. Next comes the FOR XML method posted by #GiorgosBetsos
DECLARE #t TABLE(OrderNum INT, PartNum INT, Qty INT)
INSERT INTO #t VALUES(1 , 24 , 2)
INSERT INTO #t VALUES(2 , 25 , 10)
INSERT INTO #t VALUES(3 , 24 , 5)
INSERT INTO #t VALUES(4 , 24 , 10)
SELECT OrderNum =
STUFF((SELECT ', ' + CONVERT(VARCHAR(50),OrderNum)
FROM #t b
WHERE b.PartNum = a.PartNum
FOR XML PATH('')), 1, 2, ''),
PartNum,
SUM(Qty) as Qty
FROM #t a
GROUP BY PartNum
Result
There are many ways to do this.
create table tablename (Name varchar(100), Rnk int)
Insert into tablename values
('Northshore', 1),
('F3', 2),
('Borderline', 3),
('Mattoon',3),
('Vinemane',5),
('Arizona',5),
('WestShore', 5),
('Schumburg', 5),
('Wilson',5)
--Method2
Select distinct
names= REPLACE(
(
Select a.Name as [data()]
From tablename A
Where A.Rnk = b.Rnk
Order by a.Name
FOR XML PATH ('') ), ' ', ',') ,Rnk
From tablename B Order by Rnk
OR
CREATE TABLE TestTable (ID INT, Col VARCHAR(4))
GO
INSERT INTO TestTable (ID, Col)
SELECT 1, 'A'
UNION ALL
SELECT 1, 'B'
UNION ALL
SELECT 1, 'C'
UNION ALL
SELECT 2, 'A'
UNION ALL
SELECT 2, 'B'
UNION ALL
SELECT 2, 'C'
UNION ALL
SELECT 2, 'D'
UNION ALL
SELECT 2, 'E'
GO
SELECT *
FROM TestTable
GO
-- Get CSV values
SELECT t.ID, STUFF(
(SELECT ',' + s.Col
FROM TestTable s
WHERE s.ID = t.ID
FOR XML PATH('')),1,1,'') AS CSV
FROM TestTable AS t
GROUP BY t.ID
GO
OR
CREATE TABLE #mable(mid INT, token nvarchar(16))
INSERT INTO #mable VALUES (0, 'foo')
INSERT INTO #mable VALUES(0, 'goo')
INSERT INTO #mable VALUES(1, 'hoo')
INSERT INTO #mable VALUES(1, 'moo')
SELECT m1.mid,
( SELECT m2.token + ','
FROM #mable m2
WHERE m2.mid = m1.mid
ORDER BY token
FOR XML PATH('') ) AS token
FROM #mable m1
GROUP BY m1.mid ;
Also, see this.
http://blog.sqlauthority.com/2009/11/25/sql-server-comma-separated-values-csv-from-table-column/
Maybe this is a newbie question, but
Imagine I have a report that shows the sales-order list pr sales-rep, itemized
to sku level, and want to show how many percent of the total sale of 1 sku, the sales-rep has sold.
I.e.
Sales-person
List of orders
- List of items no sold: 5 out of this months total 942
Example:
John Doe
- Order #12312
- SKU SP1231 Sold 5 . Month total 445
- SKU SP4141 Sold 63 . Month total 300
Emma Doe
- Order #123324
- SKU SP1231 Sold 65 . Month total 445
- SKU SP4141 Sold 2 . Month total 300
etc
The Month total figure is the number of items sold of that particular sku in the total reporting period.
How do I go about adding this number? If I use Fields!TotalAmount.Value it gives the total as the group'ed total. i.e. how many of sku Y was sold on order X by sales-rep Z.
I need the global total of sales of that particular SKU.
If i say SUM(Fields!Amount,Nothing) to set global scope, it gives the sum of ALL sku's, not just the sku in question.
How do I do this?
EDIT
The Report Server is SSRS, the report uses a shared Datasource that is a Report Model already hosted on the reporting server, which points to a SQL Server database with
the contents.
You didn't say what DBMS you are using (not Oracle clearly from the Fields!Amount syntax). Does this work for your DBMS?:
with sku_sales as
( select sku, sum(value) as sku_value
from sales
group by sku
)
select sales.salesperson, sum(sales.value), sku_sales.sku_value
from sales
join sku_sales on sku_sales.sku = sales.sku
group by sales.salesperson, sku_sales.sku_value
What would I do is select Sku total sum in your report dataset using comma separated lists:
-- testing data
DECLARE #Order TABLE (ID INT, SalesRepID INT, Date DATETIME)
INSERT INTO #Order
SELECT 1, 1, GETDATE() UNION
SELECT 2, 2, GETDATE() UNION
SELECT 3, 1, GETDATE() UNION
SELECT 4, 1, GETDATE() UNION
SELECT 5, 2, GETDATE()
DECLARE #OrderDetail TABLE (ID INT, OrderID INT, SkuID INT, SkuCount INT)
INSERT INTO #OrderDetail
SELECT 1, 1, 1, 10 UNION
SELECT 2, 1, 2, 5 UNION
SELECT 3, 1, 3, 20 UNION
SELECT 4, 1, 4, 10 UNION
SELECT 5, 2, 1, 15 UNION
SELECT 6, 2, 2, 25 UNION
SELECT 7, 2, 3, 15 UNION
SELECT 8, 3, 1, 15 UNION
SELECT 9, 3, 1, 10 UNION
SELECT 10, 3, 3, 10 UNION
SELECT 11, 3, 4, 15 UNION
SELECT 12, 4, 1, 5
DECLARE #Sku TABLE (ID INT, SkuCode VARCHAR(10))
INSERT INTO #Sku
SELECT 1, 'SP1233' UNION
SELECT 2, 'SP2262' UNION
SELECT 3, 'SP1531' UNION
SELECT 4, 'SP4235'
DECLARE #SalesRep TABLE (ID INT, SalesRepName VARCHAR(20))
INSERT INTO #SalesRep
SELECT 1, 'John Doe' UNION
SELECT 2, 'Emma Doe'
-- filters for testing
DECLARE #StartDate DATETIME, #EndDate DATETIME
SELECT #StartDate = GETDATE(), #EndDate = GETDATE()
DECLARE #SkuIDList VARCHAR(8000), #SkuSumList VARCHAR(8000)
SELECT #SkuIDList = '', #SkuSumList = ''
--gether all sku IDs and Sum in two comma separated list
SELECT #SkuIDList = #SkuIDList + CONVERT(VARCHAR, OD.SkuID) + ',',
#SkuSumList = #SkuSumList + CONVERT(VARCHAR, SUM(OD.SkuCount)) + ','
FROM #Order O
INNER JOIN #OrderDetail OD ON O.ID = OD.OrderID
WHERE O.Date BETWEEN #StartDate AND #EndDate
GROUP BY OD.SkuID
-- remove last ','
SELECT #SkuIDList = SUBSTRING(#SkuIDList, 0, LEN(#SkuIDList)),
#SkuSumList = SUBSTRING(#SkuSumList, 0, LEN(#SkuSumList))
-- include thouse lists in the main select for your report dataset
SELECT O.ID, OD.SkuID, O.SalesRepID, SR.SalesRepName, S.SkuCode,
OD.SkuCount, #SkuIDList AS SkuIDs, #SkuSumList AS SkuSums
FROM #Order O
INNER JOIN #OrderDetail OD ON O.ID = OD.OrderID
INNER JOIN #Sku S ON OD.SkuID = S.ID
INNER JOIN #SalesRep SR ON O.SalesRepID = SR.ID
WHERE O.Date BETWEEN #StartDate AND #EndDate
Then you can use some custome code to retrieve sum value by sku ID (I have to write in C# currently, you easely convert it to VB):
public int GetSkuSum(string skuSumCSV, string skuIDCSV, int searchSkuID)
{
string[] strSkuSum = skuSumCSV.Split(',');
string[] strSkuID = skuIDCSV.Split(',');
for (int i = 0; i < strSkuID.Length; i++)
{
if (Convert.ToInt32(strSkuID[i].Trim()) == searchSkuID)
{
return Convert.ToInt32(strSkuSum[i]);
}
}
return 0;
}
Then use it in your textbox Value expression:
=Code.GetSkuSum(Fields!SkuIDs.Value,Fields!SkuSums.Value,Fields!SkuID.Value)