我使用完全相同的查詢從兩個表中獲取數據。當我不使用c.IsReceived = 0
部件時,它將返回日期,但在使用時不會返回任何內容。在RepDailyCollection
中有的IsReceived = 0
。你認爲我做錯了什麼?這是在2005年的SQL Server。 thnak你!sql查詢返回null
Select
distinct RepDailyInfo.Date
from
RepDailyInfo
left outer join
RepDailyCollection c
on
c.RepDailyCollectionID = RepDailyInfo.RepDailyInfoID
where
RepDailyInfo.RepID = 205 and c.IsReceived = 0
編輯:
當我使用類似的其他存儲過程正常工作。
Select i.Date
--i.RepDailyInfoID, i.RepID, i.TypeofDayID, i.CommuniTeeID, sum(cast(c.AmountSold as numeric(10,2))) as AmountSold,
-- sum(cast (c.AmountCollected as numeric(10,2))) as AmountCollected, c.NewCompanyName,c.PaymentMethod,
-- c.TypeofCreditCard, c.CheckNumber, c.Invoice, c.Spots, TypeofDay.TypeofDay, CommuniTee.City, CommuniTee.State,
-- CommuniTee.year, SalesRep_Info.FirstName, SalesRep_Info.LastName
from RepDailyInfo i
left outer join RepDailyCollection c on i.RepDailyInfoID = c.RepDailyInfoID
left outer join TypeOfDay on TypeOfDay.TypeofDayID = i.TypeofDayID
left outer join SalesRep_Info on SalesRep_Info.RepID = i.RepID
left outer join CommuniTee on CommuniTee.CommuniTeeID = i.CommuniTeeID
where i.RepID = 205 and c.IsReceived = 0
group by i.RepDailyInfoID, i.Date, i.TypeofDayID, i.CommuniTeeID, SalesRep_Info.FirstName, TypeofDay.TypeofDay,
CommuniTee.City, CommuniTee.State, CommuniTee.year, SalesRep_Info.FirstName,
SalesRep_Info.LastName, i.RepID, c.NewCompanyName, c.PaymentMethod, c.TypeofCreditCard, c.CheckNumber, c.Invoice, c.Spots
order by SalesRep_Info.FirstName desc
你是對的Chris。我搞砸了查詢。 :-(我明白可能出錯了,謝謝你的時間! – Ram 2012-03-28 19:32:58