gpt4 book ai didi

mysql - 类(class)考勤记录格式SQL查询

转载 作者:行者123 更新时间:2023-11-30 23:33:40 25 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
MySQL dynamic cross tab

我有学生记录表

-------------------------------------------------------------------
student_id | semester | schoolyear| name | section |
-------------------------------------------------------------------
1 | 1st Semester| 2011-2012 | john | c21 |
2 | 1st Semester| 2011-2012 | eric | c21 |
3 | 1st Semester| 2011-2012 | mark | c21 |

和考勤表

-------------------------------------------------------------------
attendance_id | stud_id | week |
-------------------------------------------------------------------
1 | 1 | 02/04/2012 |
2 | 2 | 02/04/2012 |
3 | 3 | 02/04/2012 |
4 | 1 | 02/11/2012 |
5 | 2 | 02/11/2012 |
6 | 1 | 02/18/2012 |
7 | 2 | 02/18/2012 |
8 | 3 | 02/18/2012 |

我想使用 sql 实现此输出。

-------------------------------------------------------------------
student_id | name | 02/04/2012 | 02/11/2012 | 02/18/2012 |
-------------------------------------------------------------------
1 | john | present | present | present |
2 | erik | present | absent | present |
3 | mark | present | present | present |

这对我来说很模糊,有人可以帮忙吗?我试过了,但没用。

Select week,
[02/28/2012],
[02/29/2012]
From attendance
group by student_id

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com