所以我试图得到一个有条件的计数的总和(与查询的其余部分不同)
这是我到目前为止所拥有的:
SELECT studemo.ssid AS [SSID],
stustat.graden AS Grade,
studemo.lastname AS [Last Name],
studemo.firstname AS [First Name],
(SELECT Count(*)
WHERE attend.attendc IN ( 'E', 'G', 'H', 'I',
'J', 'L', 'M', 'P',
'Q', 'V', 'X' )) AS [Days Absent],
attend.attendc AS [Attendance Code],
attend.ddate AS [Date]
FROM track,
stustat,
stusched,
studemo,
attend
WHERE studemo.suniq = stustat.suniq
AND attend.scduniq = stusched.scduniq
AND studemo.suniq = stusched.suniq
AND stustat.trkuniq = track.trkuniq
AND track.schoolc = '408'
AND track.schyear = '2013'
AND stustat.edate >= '08/21/2012'
AND stustat.xdate IS NULL
ORDER BY [last name],
[first name],
attend.ddate
这将为我提供正确的信息,而不是以我试图获取它的方式。每个出勤代码都会给我一行。我希望做的只是将我从 count(*) 子查询中获得某些东西的次数加起来。我以大约 100 种不同的方式尝试了 sum(),但我无法得到它。有什么建议么?