我想从两个不同的表中获取数据,一个表包含学生总数,另一个表包含特定学生信息我如何获得学生人数
我想显示 name , code, totalstudent 和 no.of ngo student
select
a.name as name, a.school_code as CODE,
a.num_of_student as totalstudent,
b.COUNT (ngo_student_name) as total_student
from
ngo_student as a
INNER JOIN student_details as b on a.name=b.ngo_student_name
GROUP BY
b.ngo_student_name
此查询显示错误,请指导我 谢谢
最佳答案
尝试以下 - 您的 count(b.ngo_student_name)
而不是 b.count(ngo_student_name)
以及选择列表中的其他列应该在 group by
子句中
select
a.name as name, a.school_code as CODE,
count(a.num_of_student) as totalstudent,
COUNT(b.ngo_student_name) as total_student
from
ngo_student as a
INNER JOIN student_details as b on a.name=b.ngo_student_name
GROUP BY
a.name,a.school_code
关于sql - 如何查找不同表中的行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53004215/