Solved

filter only by one character

Posted on 2016-11-21
4
70 Views
Last Modified: 2016-11-30
Hi ,
I have data as below

mary
john simpson
L
P
KAMRA

I want result like

L
P

Thanks
0
Comment
Question by:sam2929
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Dave Ford earned 500 total points
ID: 41896645
So, are you trying to get only rows where the target column has only one character? ... or are you trying to get rows where the data in that column START with 'L' or 'P'?

 select someData                  
   from deleteMe            
  where length(trim(someData)) = 1

Open in new window


-- DaveSlash
1
 
LVL 18

Expert Comment

by:Dave Ford
ID: 41896646
I'm not really clear. What, exactly, are you trying to accomplish?
0
 
LVL 32

Expert Comment

by:awking00
ID: 41901704
For all columns with only one character -
select column from yourtable where length(column) = 1
For all columns starting with 'L' or 'P' -
select column from yourtable where substr(column,1,1) in ('L','P')
For all columns where the column value is 'L' or 'P'
select column from yourtable where length(column) = 1 and column in ('L','P')
0
 
LVL 32

Expert Comment

by:awking00
ID: 41907376
If you're only looking for one-character values in your column, then the trim function is unnecessary.
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question