我有一個包含以下數據的表格tbl_marksObtained
:如何顯示通過和失敗的學生批次總數明智
stdID sub marks_Obtained
201bct2007 computer 45
201bct2007 Drawing 0
202bct2007 computer 0
203bct2007 Drawing 65
.
230bct2007 computer 77
301bct2008 physics 0
301bct2008 computer 55
.
.
401bct2009 and so on..
現在我想顯示的結果爲:
year sub pass fail
2007 computer 20 10
2007 Drawing 15 15
2008 computer 28 2
2009 computer 20 10
我得到路過下面的代碼失敗特定年份主題:
SELECT
SUM(CASE WHEN marks_obtained > '0' THEN 1 END) AS pass,
SUM(CASE WHEN marks_obtained = '0' THEN 1 END) AS fail
FROM
tblstudentexammarks
WHERE
sub ='computer' AND stdID LIKE '%bce2007'
除H嗷嗷我會得到上述結果一年明智數據
集團通過一年?這似乎是學生ID的最後四個字符? – 2012-08-03 08:18:35