Link to home
Start Free TrialLog in
Avatar of Fred
FredFlag for United States of America

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
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial