SELECT Count(M.MatchID)
FROM Steward AS S, [Match] AS M
WHERE S.MatchID=M.MatchID AND S.StewardAllocation='YES' AND S.ExpType='No'
GROUP BY M.MatchID;
แต่พอเวลาผมเอามาใช้เป็น subquery มันไม่อนุยาดให้ group by อ่ะคับ
Code (SQL)
SELECT MatchID, MatchType, MatchDate, NoOfStewardExp, NoOfStewardNonExp,
(SELECT Count(M.MatchID) FROM Steward AS S, Match AS M WHERE S.MatchID=M.MatchID AND S.StewardAllocation='YES' AND S.ExpType='YES' ) AS ExpStewardAllocated,
(SELECT Count(M.MatchID) FROM Steward AS S, Match AS M WHERE S.MatchID=M.MatchID AND S.StewardAllocation='YES' AND S.ExpType='No' ) AS NonExpStewardAllocated
FROM Match WHERE MatchType='Home' ORDER BY MatchID ASC;