【问题标题】:Error [ORA-00979: not a GROUP BY expression] when using sum in simple linq在简单 linq 中使用 sum 时出现错误 [ORA-00979: not a GROUP BY expression]
【发布时间】:2011-10-25 12:00:35
【问题描述】:
     var dataTotalPotongan = (from x in absentContext.V_DETAIL_PELANGGARANs
                              group x by
                              new
                              {
                                  x.T_EMPLOYEE_ID,
                                  x.FINANCE_PERIOD_NAME
                              }
                                  into gruopedData
                                  select
                                  new
                                  {
                                      gruopedData.Key.T_EMPLOYEE_ID,
                                      periode = Convert.ToDateTime(gruopedData.Key.FINANCE_PERIOD_NAME), 
                                      jumlah = gruopedData.Max (x => x.FREKUENSI )
                                  }

                              );

我有那个代码,这是正确的。但每次我执行它,它总是返回

error ORA-00979: not a GROUP BY expression.

【问题讨论】:

    标签: c# linq ora-00979


    【解决方案1】:

    GROUP BY 子句不包含 SELECT 子句中的所有表达式。这是 SQL 中的标准错误。

    例如这样就可以了:

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

    但这行不通:

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

    在您的情况下,我猜您需要在 x.T_EMPLOYEE_ID 和 x.FINANCE_PERIOD_NAME 之后将 x.FREKUENSI 添加到 GroupBy 中。

    .

    【讨论】:

      猜你喜欢
      • 2013-03-10
      • 2011-04-18
      • 2021-10-26
      • 2022-01-22
      • 1970-01-01
      • 2012-11-16
      • 2021-09-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多