id date tourid pax ActivityID 1 01/04/2012 1 2 1 2 01/04/2012 2 1 2 3 01/04/2012 1 1 1 4 02/04/2012 1 1 3Then i would like to maintain an Activity table, which is the Orders table grouped by Date and TourID as in:
ActivityID Date tourid TotalOrders TotalPax 1 01/04/2012 1 3 4 2 01/04/2012 2 1 1 3 02/04/2012 1 1 1I would like a stored procedure to do the following: when adding a new Order, either create a new activityID line, or update the quantities if there already is one. When modifying an order, modify the resuting ActivityiD accordingly. Finally, i would like to save the related ActivityID in the orders table.