S
Sebastien DErrico
Guest
My task is to convert stored procedure from SQL Server to Progress code.
Everything is going well but I faced a mystery yesterday.
How can we do aggregate function like Min, Max, Avg, etc. in Progress OpenEdge V10.2B?
Here a SQL Server scenario:
WITH Inventory (ItemNo, Quantity)
AS
(
SELECT 'ItemA', 100
UNION SELECT 'ItemA', 200
UNION SELECT 'ItemC', 300
UNION SELECT 'ItemB', 400
UNION SELECT 'ItemA', 500
UNION SELECT 'ItemB', 600
)
SELECT
ItemNo
,MIN(Quantity) AS Min1
,MAX(Quantity) AS Max1
,AVG(Quantity) AS Avg1
,SUM(Quantity) AS Sum1
,COUNT(Quantity) AS Count1
FROM Inventory
GROUP BY
ItemNo
The result is:
ItemNo Min1 Max1 Avg1 Sum1 Count1
ItemA 100 500 266 800 3
ItemB 400 600 500 1000 2
ItemC 300 300 300 300 1
Thank you, Have a great day! Sebastien
Continue reading...
Everything is going well but I faced a mystery yesterday.
How can we do aggregate function like Min, Max, Avg, etc. in Progress OpenEdge V10.2B?
Here a SQL Server scenario:
WITH Inventory (ItemNo, Quantity)
AS
(
SELECT 'ItemA', 100
UNION SELECT 'ItemA', 200
UNION SELECT 'ItemC', 300
UNION SELECT 'ItemB', 400
UNION SELECT 'ItemA', 500
UNION SELECT 'ItemB', 600
)
SELECT
ItemNo
,MIN(Quantity) AS Min1
,MAX(Quantity) AS Max1
,AVG(Quantity) AS Avg1
,SUM(Quantity) AS Sum1
,COUNT(Quantity) AS Count1
FROM Inventory
GROUP BY
ItemNo
The result is:
ItemNo Min1 Max1 Avg1 Sum1 Count1
ItemA 100 500 266 800 3
ItemB 400 600 500 1000 2
ItemC 300 300 300 300 1
Thank you, Have a great day! Sebastien
Continue reading...