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 > Why am I Getting a Group By Error?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-26-11, 13:04
dvdaddict32 dvdaddict32 is offline
Registered User
 
Join Date: Mar 2010
Posts: 32
Why am I Getting a Group By Error?

Hey guys,

I can't figure out why my query is giving me errors. I'm trying to find people who are age 62 or older.

I'm getting use of reserve word GROUP is not valid. The query works fine if I take out the line where I'm searching for age. Here is my query:


Code:

SELECT    E.CTY_ID_NM,
          count(*) as COUNT
FROM     DSNP.PR01_T_MBR_SYS A, 
         DSNP.PR01_T_MBR B, 
         DSNP.PR01_T_MBR_CITY C, 
         DSNP.PR01_T_ZIP D, 
         DSNP.PR01_T_CTY E 
WHERE    A.MBR_SSN_NBR=B.MBR_SSN_NBR 
AND      A.MBR_SSN_NBR=C.MBR_SSN_NBR 
AND      C.POST_ZIP_CD=D.POST_ZIP_CD 
AND      D.CTY_ID_CD=E.CTY_ID_CD 
AND      A.MBR_STAT_CD = '1' 
and ((YEAR(CURRENT DATE) - YEAR(b.mbr_BIRTH_DT) >= 62)


group by E.CTY_ID_NM

Any ideas?
Reply With Quote
  #2 (permalink)  
Old 10-26-11, 13:15
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Please read and post with enough information to get quick, apt and meaningful responses:
Must Read before posting

Quote:
...

Please follow these guidelines to get quick, apt and meaningful responses :

1) Every question posted must include your DB2 Version, fixpack and Edition + your Operating System(including version info) + info on any third party software you use.
You can get his info using the following commands
db2level -> to get db2 version and fixpack level
db2licm -l -> to get the db2 type (WSE, ESE, etc)


2) If you question is regaring an error, make sure you post the error code, corresponding message and the command/sql which caused the error.

...
Reply With Quote
  #3 (permalink)  
Old 10-26-11, 13:15
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
It's usually advantageous to have the equal number of left and right parentheses in every SQL statement.
Reply With Quote
  #4 (permalink)  
Old 10-26-11, 14:12
db2girl db2girl is offline
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,816
Quote:
Originally Posted by n_i View Post
it's usually advantageous to have the equal number of left and right parentheses in every sql statement.
Quote:
Originally Posted by n_i View Post
what a sharp eye!
.........
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