我无法解决此查询。
表格是:
tblStandard1students
tblStandard2students
tblStandard3students
tblCandidateinfo
tblStandard1students、tblStandard2students 和 tblStandard3students tbl 包含有关参加标准 1,2 和 3 的学生的信息。
tblStandrs1students
Candid admitted
1 Y
2 N
3 Y
tblCandidateinfo
Candid gender Division
1 M 1
2 F 2
等等...
现在我想要这样的桌子
Gender Students(Standard1) Students(Standard2) Students(Standard3)
------------------------------------------------------------------------
Male 10 20 30
Female 10 30 40
我试过了,但这并没有给我错误:
SELECT case when Gender='M' then 'Male'
when Gender='F' then 'Female'
END AS Gender,
( SELECT count(*)
FROM tblStandard1students A
where A.Candid=B.Candid
) AS Students(Standard1),
( SELECT count(*)
FROM tblStandard2students A
where A.Candid=B.Candid
) AS Students(Standard2),
( SELECT count(*)
FROM tblStandard3students A
where A.Candid=B.Candid
) AS Students(Standard3)
FROM tblCandidateinfo B
group by Gender