mysql在加入时将行值显示为列

时间:2014-12-09 14:59:05

标签: mysql join

我有3张桌子

classes
id class
1  10th
2  9th
3  8th
....

students
id name    class_id...
1  smith   2
2  gyle    3
......

attendances
id  date        student_id  attendance
1   2014-01-01       1       P
2   2014-01-01       2       A
3   2014-01-02       1       P
4   2014-01-02       2       P
.....

我想在每个(分组)日期显示每个班级的现在学生总数如下

date         10th   9th   8th  .....
2014-01-01    12     11   13   .....
2014-01-02    13     11   12   .....
2014-01-01    13     10   13   .....
....................................

0 个答案:

没有答案