• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ORA-00979: not a GROUP BY expression

 
Ketan Abdar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Getting this error when i run a JPA query on a view , the query is as follows
SELECT t0.qcd, t0.qcnt, t0.qdsc, t0.qsum FROM viewname t0 WHERE ROWNUM <= 20 GROUP BY t0.qcnt, t0.qdsc, t0.qsum, t0.qcd

actually the query runs fine in SQL developer but fails in JPA entity
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you remove the table reference from the column names in the group by clause?
 
Fatih Keles
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the purpose of group by if there is no aggregate function in your select statement? If we replace "viewname" with a table this query will not fail. Can you provide a real sql statement? I suppose there is something within "viewname" (view?)
 
Ketan Abdar
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no,
i have written a named query in my JPA entity and the query is 'Select o from VStatus o', here Vstatus is the entity in JPA and in DB it is referring a view.
i have tried different forms of query given in previous post to get rid of the error but it always throws this error in logs and the list doesn't get populated,
The view has values in the database, so i dont think there is a problem in the view
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't done decent SQL in a while. After looking at Fatih's post I think I might see yhe problem. If you are doing a simple select with no aggregate function, you should be doing an ORDER BY instead of GROUP BY.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic