If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > getting error for a query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-05-04, 10:16
manth manth is offline
Registered User
 
Join Date: Mar 2004
Posts: 54
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
Reply With Quote
  #2 (permalink)  
Old 04-05-04, 10:27
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Re: getting error for a query

Quote:
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.
Reply With Quote
  #3 (permalink)  
Old 04-05-04, 10:45
manth manth is offline
Registered User
 
Join Date: Mar 2004
Posts: 54
Thumbs up

It's working fine.

Thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On