Please help me try and convert this join query. I am trying to convert the following SQL query into a LINQ query, but can not get it working. Can any one help me solve this?
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
I have only been able to do the middle bit and then get stuck on whether I need to use Contains
or Any
.
from t3 in table3
join t4 in table4 on t3.CampaignCode equals t4.CampaignCode
where t3.Month == "Sep12" && t4.ReportGroup == "testgroup"
select t3.Nurn