我有以下SQL
SELECT distinct loan_cases.case_status, count(loan_applications.id)
FROM "loan_cases"
LEFT JOIN case_statuses
ON loan_cases.id = case_statuses.loan_case_id
LEFT JOIN loan_applications
ON case_statuses.loan_application_id = loan_applications.id
GROUP BY loan_cases.case_status;
这是我的结果集
case_status | count
------------------------------+-------
Completed (End) | 28
Need Special Attention | 0
Failed (End) | 11209
Pending Submission | 1720
Pending Acceptance | 12
New | 2
Pending Follow Up Call | 2
Pending Invoicing | 63
Submitted Requires Follow Up | 0
Pending Evaluation | 11
Drop Off (End) | 566
当我运行相同的查询rails方式
LoanCase.joins("LEFT JOIN case_statuses ON loan_cases.id = case_statuses.loan_case_id LEFT JOIN loan_applications ON case_statuses.loan_application_id = loan_applications.id").group("loan_cases.case_status").select("distinct loan_cases.case_status, count(loan_applications_views.id)").size
它返回此
=> {"Submitted Requires Follow Up"=>1,
"Pending Evaluation"=>11,
"Need Special Attention"=>1,
"Failed (End)"=>11209,
"Pending Submission"=>1720,
"New"=>2,
"Drop Off (End)"=>566,
"Pending Invoicing"=>63,
"Completed (End)"=>28,
"Pending Follow Up Call"=>2,
"Pending Acceptance"=>12}
为什么将count = 0更改为count = 1?
有任何帮助表示赞赏吗?