Left Join, Group By and Sum where related records don't exist
I am trying to accomplish the following:
SELECT Table1.prod_code, SUM(Table1.prod_开发者_JAVA百科bal) AS TotalProdBalance
FROM Table1
LEFT OUTER JOIN Table2 ON Table1.prod_code = Table2.prod_code
WHERE Table2.prod_code IS NULL
GROUP BY Table1.prod_code
HAVING (SUM(Table1.prod_bal) <> 0)
Could someone help me translate this to Linq using VB.net syntax?
Check up this..
Dim query = (From rs1 in Table1
Join rs2 In Table2 On rs1.prod_code Equals rs2.prod_code
Group by record.prod_code Into TotalProdBalance = sum(rs1.prod_bal)
Where rs2.prod_code Equals Null and TotalProdBalance <> 0
Select rs1.prod_code, TotalProdBalance )
精彩评论