searchsanjaysharma
asked on
How to write sql query or stored procedure to calculate average with different no. of obseravations to get single resultset.
I have 9 subjectcode, in which every subjectcode contains the subquestions as follows.Here question 1-7 contains 12 sub questions, and 8 contains 10 subquestions, and question 9 contains 8 sub-questions, where max score that can be obtained for per subquestion is 100
and max score that can be obtained for subjectcode 1-7 is 1200, 8 is 1000 and 9 is 800.
To calculate average of subjectcode i am writing
select subjectcode,sum(totalscore )/count(*) *12 from t
group by subjectcode
Here totalscore is the totalscore of all subquestions in everysubject.
But i want this query to return a single recordset with subjectcode 8 to be divided by 10 and 9 to be divided by 8.
and max score that can be obtained for subjectcode 1-7 is 1200, 8 is 1000 and 9 is 800.
To calculate average of subjectcode i am writing
select subjectcode,sum(totalscore
group by subjectcode
Here totalscore is the totalscore of all subquestions in everysubject.
But i want this query to return a single recordset with subjectcode 8 to be divided by 10 and 9 to be divided by 8.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER