【问题标题】:Attendance of each student每个学生的出席情况
【发布时间】:2018-07-14 19:08:50
【问题描述】:

我正在尝试每月生成每个学生的出勤率。我的方法是这样的。可能是错误的,但我正在尝试这种方式。我有一个出勤表,其中包含分支、学期、部分和出勤状态(0 或 1)字段等字段。这是每天记录的。下表记录了迄今为止进行的课程总数。这是为了计算每个学生的出勤率。

我想要的是生成一个表格,其中包含学生 ID、学生截至日期参加的课程总数以及迄今为止进行的课程总数。

我尝试在学生 ID 上使用 distinct,它返回的学生 ID 没有重复,但我不明白如何生成学生参加的课程总数

我尝试了以下查询。

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

通过上述查询,我​​能够获得不重复的 student_id 以及迄今为止的班级总数。我不明白如何计算每个学生的课程数量。

【问题讨论】:

  • 没有图片谢谢
  • 好的。删除了图片

标签: mysql time-and-attendance


【解决方案1】:

我通过使用 count 和 group by 得到了解决方案。下面给出mysql代码

select a.student_id, count(*),b.totalclasses_count from attendance a,total_classes b where a.attendance_status = 1 group by a.student_id

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-09
  • 1970-01-01
  • 2021-04-21
  • 2022-11-18
相关资源
最近更新 更多