In table records as follows(Table Name Tb_Presea_Faculty_Feedback)
Feedback Facid FacQ1 FacQ2 FacQ3 FacQ4 FacQ5
1 1 5 4 3 2 2
1 2 2 3 4 5 2
1 3 3 4 5 2 3
Query as follows
select Feedbackid,sum(b.FacQ1) /3.0 as Q1,sum(b.FacQ2)/3.0 as Q2,sum(b.FacQ3)/3.0 as Q3,sum(b.FacQ4) /3.0 as Q4,sum(b.FacQ5) /3.0 as Q5 from Tb_Presea_Faculty_Feedback as b where b.Feedbackid = '1' group by Feedbackid
When i run above query output as follows
Feedbackid Q1 Q2 Q3 Q4 Q5
1 3.33 3.66 4.00 3.00 2.33
in Table records as follows(Table Name Tb_Presea_Faculty_Master)
Facid Facname
1 Gopi
2 Ram
3 Suresh
i want to display the Facname from the database. in the above query i want output as follows.
Feedbackid Facname Q1 Q2 Q3 Q4 Q5
1 Gopi 3.33 3.66 4.00 3.00 2.33
For getting a above output. i written a query as follows,
select a.Facname,b.Feedbackid,sum(b.FacQ1) /3.0 as Q1,sum(b.FacQ2)/3.0 as Q2,sum(b.FacQ3)/3.0 as Q3,sum(b.FacQ4) /3.0 as Q4,sum(b.FacQ5) /3.0 as Q5 from Tb_Presea_Faculty_Feedback as b,Tb_Presea_Faculty_Master as a where b.Feedbackid = '1' and a.Facid=b.Facid group by Feedbackid
But i execute a above query shows error as follows,
Column 'Tb_Presea_Faculty_Master.FacName' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
please help me. what is the problem in my above code.