我無法解析此查詢。Sql Query:無法對來自不同表格的數據進行分組
表是:
tblStandard1students
tblStandard2students
tblStandard3students
tblCandidateinfo
tblStandard1students,tblStandard2students和tblStandard3students TBL包含有關錄取標準1,2名學生和3
tblStandars1students
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
我沒有看到發佈的錯誤消息或使用了'ORDER BY'。你的意思是「GROUP」而不是「SORT」嗎? – 2013-03-07 07:07:50
@ pst對不起!編輯了這個問題。 – user1274646 2013-03-07 07:11:54