Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2010
    Posts
    32

    Unanswered: 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?

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Please read and post with enough information to get quick, apt and meaningful responses:
    http://www.dbforums.com/db2/854783-m...e-posting.html

    ...

    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.

    ...

  3. #3
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    It's usually advantageous to have the equal number of left and right parentheses in every SQL statement.

  4. #4
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,367
    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!
    .........

Posting Permissions

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