Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need Help in SQL query for identifying records havain 2 word

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Need Help in SQL query for identifying records havain 2 word
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: 1278
Location: Belgium

PostPosted: Tue Sep 13, 2011 6:42 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us