mercredi 29 juin 2016

MySQL query to count 1's occurrence in different columns of feedback table


I want to count all the occurrence of '1' in the columns commskill, abilityskill, interest, presentation, methodology, maintainsclass, punctual, attitude. My table 'Feedback' has following columns:

  • Fid-feedback I'd
  • Tname- teacher name
  • Sname-subject name
  • Studentname- students name
  • Class- class of students
  • Section - section of class
  • commskill- communication skill
  • abilityskill- ability of teaching
  • Presentation - presentation skills of teacher
  • Methodology - method for teaching followed by teacher
  • Interest - interest of students in that teacher's class
  • Punctual - time punctuality of teachers
  • maintainsclass- maintains class discipline
  • attitude - attitude of teacher towards students *tid- teacher 's ID

The values of fid are auto-increment,and grades of all skills are in(1-excellent, 2-good, 3-average,4-below average).

I've already tried this query:

select tname,sname,count(*) as excellent from feedback where commskill=1 or attitude =1 or presentation =1 or abilityskill=1 or interest=1 or punctual =1 or maintainsclass=1 or methodology =1 group by tid;

but the answer showed is unexpected and wrong.


Aucun commentaire:

Enregistrer un commentaire