select count(*) total, sum(case when stu_community = 'BC' then 1 else 0
end) bc, b.branch_name FROM admission_details a, stu_personal_details p,
stu_contact_details c, current_course curr,degree d, courses co, branch
b WHERE a.admission_no = p.admission_no AND p.stu_rollno = c.stu_rollno
AND c.stu_rollno = curr.stu_rollno AND curr.stu_rollno = p.stu_rollno
AND (curr.stu_branch IN (18,19,20) AND d.degree_id = curr.stu_degree AND
co.course_id = curr.stu_course AND b.branch_id = curr.stu_branch)
但
我想要来自每个分支的计数值和每个社区在同一个查询中它可以吗?我想要这样的结果
我该怎么办?请帮忙
答案 0 :(得分:0)
您需要使用group by
函数来获得预期结果
添加
group by b.branch_name