This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC and the fly likes ORA-00979: not a GROUP BY expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "ORA-00979: not a GROUP BY expression" Watch "ORA-00979: not a GROUP BY expression" New topic
Author

ORA-00979: not a GROUP BY expression

Ketan Abdar
Greenhorn

Joined: Jun 13, 2011
Posts: 2
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

Joined: May 04, 2011
Posts: 144

What happens if you remove the table reference from the column names in the group by clause?


OCJP6, OCWCD5
Fatih Keles
Ranch Hand

Joined: Sep 01, 2005
Posts: 182
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

Joined: Jun 13, 2011
Posts: 2
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

Joined: May 04, 2011
Posts: 144

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.
 
GeeCON Prague 2014
 
subject: ORA-00979: not a GROUP BY expression