I am looking to create a stored procedure to create a new table from a dump table. In the table is ID, ResidentID, Village and answers to a survey. I would like the new table to be created with the averages for each question but only for specific answers. What I would like to do is get the average for each village for each question that has a 3 or 4 answered for each question but then divide by the number of surveys for that specific village.
If AT has 34 surveys answered and 7 answered 4 for I am happy and 8 answered 3 for I am happy. I want to do 7+8/34 and put that into the table for AT.