Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 converting a mainframe file with ASA ... Lynne Schuler All Other Mainframe Topics 5 Wed Apr 04, 2018 9:44 am
No new posts Extract the records with a PD field's... sudhakar84 DFSORT/ICETOOL 11 Mon Apr 02, 2018 7:26 pm
No new posts Merge 2 records sancraig16 SYNCSORT 19 Tue Mar 27, 2018 8:17 pm
No new posts Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am
No new posts Copy set of records based on condition krish.deepu SYNCSORT 2 Thu Mar 08, 2018 11:39 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us