Я использовал один и тот же запрос для получения данных из двух таблиц.когда я не использую часть c.IsReceived = 0
, она возвращает даты, но ничего не возвращает при использовании.В RepDailyCollection
есть строки с IsReceived = 0
для RepID = 205
.Что ты думаешь я делаю не так?Это в 2005 году SQL Server.спасибо !!
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