开发者

Group By and aggregate on a calculated column

Any suggestions please on how to change this Linq to Entities (VB.Net) query to Group by L2_ID column and aggregate the calculated column diff as Sum for the group.

Thanks

From l In Level3s 
Join a In BaseLines On l.L3_ID Equals a.L3_ID 
Order By l.L2_ID 
Select Activity = l.L2_ID, Diff = (a.ACT_DATE.Day - l.ACT_DATE.Day开发者_运维技巧)


Try two consecutive queries:

Dim q = From l In context.Level3s _
        Join a In contexts.BaseLines On l.L3_ID Equals a.L3_ID _
        Order By l.L2_ID _
        Select Activity = l.L2_ID, Diff = (a.ACT_DATE.Day - l.ACT_DATE.Day)
Dim q1 = From el In q _
         Group By Key = el.Activity Into G = Sum(el.Diff) _
         Select Key, G
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜