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!?!?!?!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Wow, the same answer in the same minute. That's impressive.
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!
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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!
Since these kinds of things are case-sensitive, are you absolutely sure that a lowercase "x" exists in the data?
-- DaveSlash