IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Fetch records with a column having non-specified characters


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
soundarr

New User


Joined: 17 Jan 2008
Posts: 25
Location: Chennai

PostPosted: Tue Jul 07, 2009 3:00 pm
Reply with quote

Dear All,

Can you please suggest the easiest way to fetch records from a table with a column (char) having characters other than non-specified values.

For example: I need values which have characters other than A, B and C

i/p :
AC
ABC
ACD
IFB
GABC

o/p:
ACD
IFB
GABC

Thanks for having a look!

Best Regards,
Soundar
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jul 07, 2009 3:26 pm
Reply with quote

Sounds like a class project
you only want ROWS (there are no records in db2 tables)
which contain char D thru Z? (don't care about spaces, special char, lower case or numeric)
How large is the Column? (what is the length)

assuming that it is a 4 char column

Code:

SELECT ?
FROM table
WHERE SUBSTR(column,1,1) > 'D'
   OR SUBSTR(column,2,1) > 'D'
   OR SUBSTR(column,3,1) > 'D'
   OR SUBSTR(column,4,1) > 'D'


you could also reverse it and make it
WHERE
SUBSTR(column,1,1) > 'D'
or
SUBSTR(column,1,1) < 'A'
or
...
Back to top
View user's profile Send private message
soundarr

New User


Joined: 17 Jan 2008
Posts: 25
Location: Chennai

PostPosted: Tue Jul 07, 2009 3:44 pm
Reply with quote

To be exact, I need ROWS with characters other than A-Z, "-" and SPACE. Column is 200 characters long.

Thanks and Regards,
Soundar
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
Search our Forums:

Back to Top