0
我試圖顯示行,即使它們返回的計數爲零。然而沒有運氣。 我嘗試使用左連接。顯示具有零計數的行
select
a.Month,
count(b.InsuranceFromJob) [Number of Participants without Insurance]
from
hsAdmin.ReportPeriodLkup a
left join hsAdmin.ClientReport b on
b.ReportPeriod = a.ReportPeriodId
where
b.insurancefromjob = 2 and
a.reportperiodid between (@lastReportId - 11) and @lastReportId
group by
a.Month
嘗試次數使用'coalesce'或'zeroifnull'命令。請提及數據庫名稱。 – minatverma
您在'WHERE'子句中對錶別名'b'有限制,所以您已經有效地將'LEFT OUTER JOIN'變成了'INNER JOIN'。 –
嘗試將謂詞'b.insurancefromjob = 2'移動到'ON'子句 –