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

Need Help in SQL query for identifying records havain 2 word


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

New User


Joined: 13 Sep 2011
Posts: 1
Location: india

PostPosted: Tue Sep 13, 2011 5:20 pm
Reply with quote

Hi,

I am facing one issue. I have to write one query which will select only those records, which are having 2 words only in a particular column. I tried several join scenarios, but that didn't work.

Let take an eg.
Suppose i am having the following list.

Sunil
Sunil Kumar
Sunil Kumar Pandey
Sandeep
Sandeep Srivastava
Sanjay
Sanjay Potdar
Sanjay Pnadurang Potdar

So the result should be:
Sunil Kumar
Sandeep Srivastava
Sanjay Potdar

Please help me in writing that query.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Sep 13, 2011 6:42 pm
Reply with quote

Code:
select
col1
 from Table1
 where length(strip(col1)) - length(replace(strip(col1),' ','')) = 1
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 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top