【发布时间】:2016-08-20 11:27:48
【问题描述】:
我有一个名为attendance 的表,其中包含roll、class_id、status 和att_date 列。
我有另一个名为class 的表,其中包含class_id 和name 列。
我想选择不同的class_id 并计算number 的roll 有status = 1 where date="some_date" 然后使用inner join. 将其连接到班级表并再次应用 where branch ="Computer science"
但是我遇到了一些问题。 这是我的餐桌考勤示例:
roll | class_id | status | att_date
abc | 1 | 0 | 19-06-2016
cvb | 2 | 1 | 19-06-2016
nbs | 1 | 1 | 19-06-2016
lkl | 3 | 1 | 19-06-2016
ewq | 3 | 1 | 19-06-2016
dff | 2 | 1 | 19-06-2016
xyz | 2 | 1 | 19-06-2016
这是我的表格类的一个例子:
id | name | branch
1 | CS4 | Computer Science
2 | CS5 | Computer Science
3 | CS6 | Mechanical
我想要这样的东西:
total number of roll with status 1 | class_id | name
1 | 1 | CS4
3 | 2 | CS5
2 | 3 | CS6
谁能解释一下?
我该如何处理查询?
【问题讨论】:
标签: mysql