2012-11-07 164 views
-1

請幫我試試並轉換此連接查詢。我試圖將以下SQL查詢轉換爲LINQ查詢,但無法使其工作。任何人都可以幫我解決這個問題嗎?無法將SQL查詢轉換爲Linq

SELECT T1.BoCode, case when T2.qty is null then 0 else T2.qty end 
FROM 
    (SELECT bocode from TABLE1) as T1 
left join 
    (SELECT cBoCode, sum(qty) as qty FROM TABLE2 where ncampnurn in 
     (select nurn FROM TABLE3 INNER JOIN TABLE4 ON TABLE3.CampaignCode = 
     TABLE4.CampaignCode 
     where TABLE3.Month = 'Sep12' and TABLE4.ReportGroup = 'testgroup') 
    GROUP BY cBoCode) as T2 
ON T1.BoCode = T2.cBoCode 
order by T1.BoCode 

我只能夠做的中間位,然後卡住我是否需要使用ContainsAny

from t3 in table3 
join t4 in table4 on t3.CampaignCode equals t4.CampaignCode 
where t3.Month == "Sep12" && t4.ReportGroup == "testgroup" 
select t3.Nurn 

回答