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 Identifying Interfaces in CICS/mainframe Ashishpanpaliya CICS 5 Fri Oct 13, 2017 3:21 pm
No new posts sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Addition of two records on 2 fields amar143 SYNCSORT 8 Tue Oct 03, 2017 11:14 am
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm

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