Fred
asked on
How can I define the values in the columns. I want to use the Sum/Count aggregate functions and use GROUP BY STATEMENT in a temp table
I am creating a Temporary table, How can I define the values in the columns. I want to use the Sum/Count aggregate functions and use GROUP BY STATEMENT ?
CREATE TABLE #ProductionInFo (ProductID, COUNT(*) ProductCount,SUM(LineTotal ) TotalSales)
INSERT INTO #ProductionInFo
SELECT ProductID, COUNT(*) ProductCount,SUM(LineTotal ) TotalSales
FROM Sales.SalesOrderDetail
GROUP BY ProductID
Order by ProductID
SELECT * FROM #ProductionInfo
SELECT ProductID, COUNT(*) ProductCount,SUM(LineTotal ) TotalSales
FROM Sales.SalesOrderDetail
GROUP BY ProductID
Order by ProductID
CREATE TABLE #ProductionInFo (ProductID, COUNT(*) ProductCount,SUM(LineTotal
INSERT INTO #ProductionInFo
SELECT ProductID, COUNT(*) ProductCount,SUM(LineTotal
FROM Sales.SalesOrderDetail
GROUP BY ProductID
Order by ProductID
SELECT * FROM #ProductionInfo
SELECT ProductID, COUNT(*) ProductCount,SUM(LineTotal
FROM Sales.SalesOrderDetail
GROUP BY ProductID
Order by ProductID
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.