Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2004
    Posts
    54

    Unanswered: getting error for a query

    Hi,

    When i try the following query, i am getting the given result below.

    db2 => SELECT DISTINCT ERRCODE, COUNT(ERRCODE) FROM DB2ADMIN.CFGERRLOG GROUP BY ERRCODE

    ERRCODE 2
    ------------------------ -----------
    AM2741 6
    AM5569 4
    IM0016 114
    IM0043 129
    IM0046 2
    IM0048 188
    IM0051 186

    If i want to see ERRTEXT along with the above result, i am getting the given error below

    db2 => SELECT DISTINCT ERRCODE, ERRTEXT, COUNT(ERRCODE) FROM DB2ADMIN.CFGERRLOG GROUP BY ERRCODE

    Error:
    SQL0119N An expression starting with "ERRTEXT" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a column function and no GROUP BY clause is specified. SQLSTATE=42803

    What could be the problem??

    Please help me.

    Thanks

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1

    Re: getting error for a query

    Originally posted by manth
    Hi,

    When i try the following query, i am getting the given result below.

    db2 => SELECT DISTINCT ERRCODE, COUNT(ERRCODE) FROM DB2ADMIN.CFGERRLOG GROUP BY ERRCODE

    ERRCODE 2
    ------------------------ -----------
    AM2741 6
    AM5569 4
    IM0016 114
    IM0043 129
    IM0046 2
    IM0048 188
    IM0051 186

    If i want to see ERRTEXT along with the above result, i am getting the given error below

    db2 => SELECT DISTINCT ERRCODE, ERRTEXT, COUNT(ERRCODE) FROM DB2ADMIN.CFGERRLOG GROUP BY ERRCODE

    Error:
    SQL0119N An expression starting with "ERRTEXT" specified in a SELECT clause, HAVING clause, or ORDER BY clause is not specified in the GROUP BY clause or it is in a SELECT clause, HAVING clause, or ORDER BY clause with a column function and no GROUP BY clause is specified. SQLSTATE=42803

    What could be the problem??

    Please help me.

    Thanks
    You need to group by errtext as well. By the way, "DISTINCT" is not needed where you're using it - GROUP BY has the same effect.

  3. #3
    Join Date
    Mar 2004
    Posts
    54

    Thumbs up

    It's working fine.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •