Click here to Skip to main content
15,879,348 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
In table record as follows


Course Batch Feedbackid MQ1 MQ2 MQ3 MQ4 Entereddate

A B101 1 4 5 3 2 9 jun 2014
B B102 2 6 4 9 1 10 jun 2014


i want to sum the MQ1 to MQ4 (4+5+3+2) divide by 4 = 3.5


for this i how to write the sql
please help me
Posted
Comments
agent_kruger 13-Jun-14 4:37am    
sir, as you have put up the question i would like to recommend you to go back and try it yourself, it is kind of easy and still i have posted the answer. Sorry if the above statement was rude.

sir, it is kind of simple here is the code
Select ((MQ1+MQ2+MQ3+MQ4)/4.00) As SumOfTotalVal from Table1
 
Share this answer
 
SQL
CREATE TABLE #MySum(Course VARCHAR(10),Batch VARCHAR(50),FeedbackID INT,MQ1 INT,MQ2 INT,MQ3 INT,MQ4 INT,EnteredDate Date)

INSERT INTO #MySum VALUES ('A','B101',1,4,5,3,2,GETDATE()),
                          ('B','B102',2,6,4,9,1,GETDATE())




                          SELECT * ,(MQ1 +MQ2 +MQ3 +MQ4)  /4.0 'SUM' FROM #MySum
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900