我已經編寫了一個查詢來從聯合檢索結果。但它顯示了兩行的結果並將空列留爲0.但是我需要一行結果而不需要零。任何人都可以請幫我。下面是我的查詢下面給出我已經寫了兩個部分>>>從聯合查詢中獲取單個行的字段
SELECT COUNT(gi.id) AS no_of_group ,
0 AS no_of_borrower
FROM group_info AS gi
WHERE gi.domain_status_id = 1
AND gi.group_status_id = 1
AND gi.group_creation_date <= '2013-01-31'
AND gi.project_info_id = 'BI0000000000000000000001'
AND gi.branch_info_id = 'BI0000000000000000000363'
UNION
SELECT 0 AS no_of_group ,
COUNT(outerlat.member_info_id) AS no_of_borrower
FROM
(SELECT lat.member_info_id,
MAX(lat.id) AS max_member_id
FROM loan_account_transaction AS lat
WHERE lat.project_info_id = 'BI0000000000000000000001'
AND lat.country_id = 1
AND lat.domain_status_id = 1
AND lat.office_info_id = 'BI0000000000000000000363'
AND lat.transaction_date <= '2013-01-31'
GROUP BY lat.member_info_id) AS tempData
INNER JOIN loan_account_transaction AS outerlat ON (tempData.max_member_id = outerlat.id)
WHERE outerlat.loan_status_id IN(1,3,4,5)
這是MySQL還是SQL Server? – 2013-03-19 12:25:38