我的左外连接保持返回完全重复,直到我向查询添加了distinct。这是为什么?如何将此查询转换为LINQ:
SELECT distinct
ADCIC.AccountDairyToCommitmentItemCategoryID,
ADCIC.AccountDairyParentID
from
vw_ParentAccountDollarsAllocatedByCommitmentItemCategory vw
left outer join tblAccountDairyToCommitmentItemCategory ADCIC
ON vw.AccountDairyParentID = ADCIC.AccountDairyParentID
where
vw.FiscalYear = 2015
AND vw.AccountDairyParentID = 6478
答案 0 :(得分:0)
这是一个疯狂的猜测,我知道我可能会得到这个但是
检查tblAccountDairyToCommitmentItemCategory表是否有FiscalYear列,如果是,那么我认为你需要在你的连接条件中添加FiscalYear
您可能想尝试以下查询
SELECT
ADCIC.AccountDairyToCommitmentItemCategoryID,
ADCIC.AccountDairyParentID
from
vw_ParentAccountDollarsAllocatedByCommitmentItemCategory vw
left outer join tblAccountDairyToCommitmentItemCategory ADCIC
ON vw.AccountDairyParentID = ADCIC.AccountDairyParentID
and vw.FiscalYear = ADCIC.FiscalYear
where
vw.FiscalYear = 2015
AND vw.AccountDairyParentID = 6478