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: 1281
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 Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am


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