-1

I am trying to generate attendance of each student on a monthly basis. My approach is this way.. May be wrong but I am trying this way. I have an attendance table which has fields like branch, semester, section, and the attendance_status(0 or 1) field. this is recorded on a daily basis. The next table keeps a count of total number of classes conducted till date. This is to calculate the attendance percentage of each student.

What I want is to generate a table which contains student id, total number of classes attended till date by student and the total number of classes conducted till date.

I tried using distinct on student id which returns me student id without duplicates but i am not understanding how to generate the total count of classes attended by student

I have tried the following query.

select distinct a.student_id, b.totalclasses_count from bkec_attendance a,total_classes b where a.attendance_status = 1

With the above query I am able to achieve the student_id without duplicates and the total number of classes till date. I am not understanding how to get the count of classes present for each student.

Havish
  • 33
  • 7

1 Answers1

0

I got solution by using count and group by. The mysql code is given below

select a.student_id, count(*),b.totalclasses_count from attendance a,total_classes b where a.attendance_status = 1 group by a.student_id
Havish
  • 33
  • 7
  • This is not the solution. See https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query – Strawberry Jul 14 '18 at 22:57
  • You mean to say I should provide a sqlfiddle? – Havish Jul 15 '18 at 04:19