Solved

filter only by one character

Posted on 2016-11-21
4
32 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
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
daveslash 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:daveslash
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now