1

私は欠席者用のテーブルを持っており、そのテーブルには欠席した人の学生IDが保存されています。

このテーブルから、総プレゼンティと総欠席者を見つける必要がありました。このために、特定のセクションの最大容量を含むセクションテーブルに参加しました。

このための私のクエリは

select COUNT(Attendance.studentid) as Absentees
        ,Sections.Max-count(studentid) as Presentees
from Attendance
inner join Students
on students.StudentId=Attendance.StudentId
inner join Sections
on Sections.CourseId=students.CourseId
group by Sections.Max

うまく機能しているのと同じように、性別ごとの発表者/欠席者を見つける方法......性別の列が学生の表にあります。誰かが私にアイデアを教えてくれますか、事前に感謝します

4

1 に答える 1

5

select ...性別の列を列とに追加するだけで、性別group byごとに 1 つの行が作成されます。

select COUNT(Attendance.studentid) as Absentees,
       Sections.Max-count(studentid) as Presentees,
       Students.Gender as Gender
from Attendance
inner join Students
on Students.StudentId=Attendance.StudentId
inner join Sections
on Sections.CourseId=Students.CourseId
group by Sections.Max, Students.Gender
于 2012-04-12T06:56:06.623 に答える