Many, many thanks Ajit that worked once I changed on a.cn_ref = b.ct_ref to on a.cn_ref equals b.ct_ref
Paul -----Original Message----- From: ProfoxTech [mailto:[email protected]] On Behalf Of Ajit Abraham Sent: 07 January 2016 09:38 To: [email protected] Subject: Re: [NF] SQL SELECT to LINQ Hello Paul, One possible solution from stackoverflow bit.ly/1TGzfLp from a in cn_ref join b in cn_desc on a.cn_ref = b.ct_ref group new {a.cn_ref, a.cn_desc, b.ct_quan} by new {a.cn_ref, a.cn_desc } into gc select new { cn_ref = gc.Key.cn_ref, cn_desc = gc.Key.cn_Desc, quantity = gc.ToList().Sum(p=>p.ct_quan) } To sort you can wrap the above in brackets and put a .Orderby(x=>x.cn_ref) I tested it on Linqpad. It works - but the SQL output is verbose compared to your SQL statement. Ajit Abraham On 06/01/2016 18:09, Paul Newton wrote: > Hi all > > I am just starting out with LINQ and am struggling a bit so I wondered > if any kind could help me out with converting the following to LINQ > > select cn_ref, cn_desc, sum(ct_quan) as Quantity from cname join ctran > on cn_ref=ct_ref group by cn_ref,cn_desc order by cn_ref > > Any offers of help would be much appreciated > > Paul Newton > [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[email protected] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

