1
我有一種情況,我需要根據某個列值 (如下所示)對申請人進行分組,並查找該組的計數。 當前查詢只返回那些數量大於0的列。檢查病例報告中所有組的檢查數
應該對查詢做些什麼修改才能顯示所有組及其計數爲零?
查詢:
select Applicant_info.range as [Income Range], count(*) as [Total Students],order_number =
CASE range
WHEN 'Did not specify' THEN '1'
WHEN '0-25000' THEN '2'
WHEN '25001-50000' THEN '3'
WHEN '50001-75000' THEN '4'
WHEN '75001-100000' THEN '5'
WHEN '100001-200000' THEN '6'
WHEN '200000 and Above' THEN '7'
END
from (
select case
when Annual_Income is null or Annual_Income = '' then 'Did not specify'
when Annual_Income between 0 and 25000 then '0-25000'
when Annual_Income between 25001 and 50000 then '25001-50000'
when Annual_Income between 50001 and 75000 then '50001-75000'
when Annual_Income between 75001 and 100000 then '75001-100000'
when Annual_Income between 100001 and 200000 then '100001-200000'
when Annual_Income > 200000 then '200000 and Above'
end as range
from Applicant_info)Applicant_info
group by Applicant_info.range
order by order_number
@Shah - 你是否有錯誤,如果是的話,編輯你的問題,並在那裏添加它們或在這裏留言。 –
是的範圍造成的問題,在評論它後,它工作正常 – Shah