【发布时间】:2013-06-26 19:34:14
【问题描述】:
我想知道如何通过按月和总计数分组来解决我的 Linq 问题。
以下是我的示例数据:
Code CodeName Color Month
11111 One Red 1
11111 One Red 1
11111 One Red 2
22222 Two Green 2
33333 Three Yellow 3
44444 Four Blue 4
44444 Four Blue 4
55555 Five White 5
我希望看到这样的结果:
Code CodeName Color Count(Mont1) Month2 Month3 Month4 Month5
11111 one red 2 1 0 0 0
22222 two Green 0 1 0 0 0
33333 three Yellow 0 0 1 0 0
44444 four Blue 0 0 0 2 0
55555 five White 0 0 0 0 1
【问题讨论】:
-
那么到目前为止你尝试过什么?
-
寻找 LINQ + pivot 并发现没有灵丹妙药。以前曾以多种方式提出过这个问题。