How can we create the procedure using AVG and sum functions

  • Hi

    I have table Source_Data which contatins the data from the flat file.By using this data now i need to load 3 different tables which has to be done sequentially

    say for eg i have a prodeuct information in the file.I need to load the Tables 1)Product_Fact 2)Product_Type_Fact and 3)Order_number_Fact

    1Product contains > multiple Product_Types >One Product_type contains>Multiple Orders_Numbers

    Now i need the fallowing

    1)calculate Avg(sales) for the each order from the Source_Data and load into Order_number_Fact table

    2)Calculate the Avg(Sales) for each Product_Type and load into Product_Type_Fact irrespective of Order_Number

    3)Calculate the Avg(Sales) for each Procduct and Load into Procuct irrespective of Product_Type.

    Finally the table

    1)Procduct should contain Avg(sales) on Product level

    2)Procduct_type should contain Avg(sales) on Product_type level

    3)Order_number should contain Avg(sales) on Order_number level

    Pls help me out to put this logic in the Stored procedure.

    Thanks In Advance

  • It's hard to answer this question without some more information.

    You should provide DDL script for tables and some sample data.

    I suggest you take a look at this article

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    and come back with some more info.

    Regards

    Gianluca

    -- Gianluca Sartori

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply