Link to home
Start Free TrialLog in
Avatar of morciani
morciani

asked on

simply SQL query against DB2 table

Hi All,

This is a simple SQL query that I am trying to run against a DB2 data table:

SELECT COUNT(*) AS SETUPS, YEAR (LAST_MOD_DT_TM) AS YEAR
FROM SCHEMA1.SETUP WHERE DDA_ID>''
AND DDA_ID LIKE ('%x%')
GROUP BY YEAR (LAST_MOD_DT_TM)  

This query returns no results:
                           
      SETUPS         YEAR  
 -----------  -----------  

There are definitely records in the table that match!

I can change a single character in the query (x to *), as follows:

SELECT COUNT(*) AS SETUPS, YEAR (LAST_MOD_DT_TM) AS YEAR
FROM SCHEMA1.SETUP WHERE DDA_ID>''
AND DDA_ID LIKE ('%*%')
GROUP BY YEAR (LAST_MOD_DT_TM)

The query returns the expected results:

                             
        SETUPS         YEAR  
   -----------  -----------  
            31         2007  
            65         2008  
                             
I'm just looking for records in the table that contain an 'x' in the DDA_ID field.  What gives!?!?!?!
SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

Since these kinds of things are case-sensitive, are you absolutely sure that a lowercase "x" exists in the data?

-- DaveSlash

Wow, the same answer in the same minute. That's impressive.
Avatar of morciani
morciani

ASKER

HI all- sorry about the delay in this comment.

I've tried the query using 'x' and 'X'..... still no records returned.  There are definitely records in the database that contain 'x' (lowercase).  My data ONLY includes records with lowercase x's.... no upper case X's exist.  
The data contains the following unique characters: 1,2,3,4,5,6,7,8,9,0,*,-,x.  I can run the query and get expected results with every character, except 'x'.  Crazy!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I don't have admin access to the database, so I will have to give up on this one.  Oh well- thank you for the help!