我有一个包含两列的表,即teacherid
和sub_group
。现在, sub_group 的值可以在 0-100 之间,其中 0 表示教师讲座,大于 0 表示教程。我希望能够计算教师分组的讲座和教程的数量。
到目前为止,我有两个查询,例如
SELECT teacherid, count(*) as lectures FROM `ttresponsibility` where sub_group = 0
group by teacherid
SELECT teacherid, count(*) as tutorials FROM `ttresponsibility` where sub_group > 0
group by teacherid
我想将两者的结果合并到一个结果集中,例如
teacher lectures tutorials
1 15 10
2 14 8
请建议...