Tuesday, August 19, 2014

ORA-00979: not a GROUP BY expression

This error happens when the GROUP BY clause does not include all the fields in the SELECT and ORDER BY clauses.

For example, the following queries throw the "not a GROUP BY expression" error.

1. SELECT name, cost, customerID from ORDER GROUP BY customerID;

2. SELECT name, cost, customerID from ORDER GROUP BY customerID, name, cost ORDER BY orderID;

To fix this error, you may either add all the fields in the SELECT and ORDER BY clauses to the GROUP BY clause or completely remove the GROUP BY clause from the query or remove whatever is not in the GROUP BY clause from the SELECT and the ORDER BY clauses whichever serves you better.

To fix the above two queries, you may do the following modification.

1. SELECT name, cost, customerID from ORDER GROUP BY customerID, name, cost;

2. SELECT name, cost, customerID from ORDER GROUP BY customerID, name, cost, orderID ORDER BY orderID;

-------------------------------------------------------------------------------------------------------------

                        
If you have ever asked yourself these questions, this is the book for you. What is the meaning of life? Why do people suffer? What is in control of my life? Why is life the way it is? How can I stop suffering and be happy? How can I have a successful life? How can I have a life I like to have? How can I be the person I like to be? How can I be wiser and smarter? How can I have good and harmonious relations with others? Why do people meditate to achieve enlightenment? What is the true meaning of spiritual practice? Why all beings are one? Read the book free here.

2 comments:

  1. Excellent posts Joy. I have problem ORA-01013: user requested cancel of current operation. I am not figure out why this is happening. Please help.

    ReplyDelete
  2. I have never had such an error myself, but I did find some relative websites online. Please read the articles at the following websites.

    http://www.dba-oracle.com/t_ora_01013_user_requested_cancel_of_current_operation.htm

    http://community.microfocus.com/borland/test/silk_performer_-_application_performance_testing/w/knowledge_base/9239.why-do-i-receive-the-error-ora-01013-user-requested-cancel-of-current-operation.aspx

    https://community.oracle.com/message/10369199

    ReplyDelete