开发者

Error [ORA-00979: not a GROUP BY expression] when using sum in simple linq

     var dataTotalPotongan = (from x in absentContext.V_DETAIL_PELANGGARANs
                              group x by
                              new
                              {
                                  x.T_EMPLOYEE_ID,
                                  x.FINANCE_PERIOD_NAME
                              }
                                  i开发者_如何学运维nto gruopedData
                                  select
                                  new
                                  {
                                      gruopedData.Key.T_EMPLOYEE_ID,
                                      periode = Convert.ToDateTime(gruopedData.Key.FINANCE_PERIOD_NAME), 
                                      jumlah = gruopedData.Max (x => x.FREKUENSI )
                                  }

                              );

I have that code, which is correct. but everytime I execute it, it always returns

error ORA-00979: not a GROUP BY expression.


The GROUP BY clause does not contain all the expressions in the SELECT clause. This is standard mistake in SQL.

For instance this is ok:

SELECT Customer,OrderDate,SUM(OrderPrice) 
FROM Orders
GROUP BY Customer,OrderDate 

But this wont work:

SELECT Customer,OrderDate, OrderPrice 
FROM Orders
GROUP BY Customer,OrderDate

In your case I guess you need to add x.FREKUENSI into GroupBy after x.T_EMPLOYEE_ID and x.FINANCE_PERIOD_NAME.

.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜