I'm trying to make a query using order by and group by at the same time But I'm taking a following error:
ORA-00979: not a GROUP BY expression
Here is query's code:
@Query("select distinct p from PointSpreadsheets p left join fetch p.shlSpreadsheetRegistersList srl" +
" WHERE (:BUAPP is null OR srl.buApprobation = :BUAPP)" +
" AND (:STATUS is null OR p.idStatus = :STATUS)" +
" AND (:CCAPP is null OR srl.ccApprobation = :CCAPP)" +
" AND (:EMPLOYEE is null OR p.idEmployee = :EMPLOYEE)" +
" AND (:CCLIST is null or srl.idCostCenter = :CCLIST)" +
" AND (p.idEmployee.idBusinessUnit IN (:BU))" +
" AND (p.referencePeriod.idReferencePeriod IN :PERIODS)"
+ " GROUP BY"
+ " p.buApprobation, p.ccApprobation, p.dateBuApprobation,"
+ " p.dateCcApprobation, p.finalDate, p.idEmployee, p.idPeriodicity,"
+ " p.idSpreadsheet, p.idStatus, p.initialDate, p.referencePeriod"
+ " ORDER BY p.idEmployee")
public List<PointSpreadsheets> PointSpreadsheetFilter(
@Param("STATUS") BigDecimal status,
@Param("BUAPP") BigDecimal buApprobation,
@Param("CCAPP") BigDecimal ccApprobation,
@Param("PERIODS") List<BigDecimal> periods,
@Param("EMPLOYEE") Employees employee,
@Param("BU") List<BusinessUnits> businessUnits,
@Param("CCLIST") CostCenter cc);