我正在使用winforms
.NET 3.5 并sql server 2005
使用 c#。
我需要加入 3 个表,例如Advance_cost
,room_no_info
并bill
使用内部联接...
SELECT
bill.bill_no AS BillNo
, COUNT(room_no_info.room_number) AS TotalRoom
, CONVERT(VARCHAR(11), room_no_info.in_date, 106) AS InDate
, CONVERT(VARCHAR(11), room_no_info.out_date, 106) AS OutDate
, bill.total AS Amount
, Advance_cost.total_amount AS Advance
, Advance_cost.total_amount AS Paid
, bill.Balance AS Balance
FROM room_no_info
INNER JOIN bill ON bill.bill_no = room_no_info.bill_no
INNER JOIN Advance_cost ON bill.bill_no = Advance_cost.room_bill_no
AND bill.Date = '26-Jun-13'
GROUP BY
bill.bill_no
, room_no_info.in_date
, room_no_info.out_date
, bill.total
, Advance_cost.total_amount
, bill.Balance
表中的advance_cost
数据可能为空或没有日期的数据bill.date
。所以连接中的第三个条件为假所以它不显示一些数据但是Advance_cost.total_amount=0
当第三个表值变空时我需要
有什么想法吗?