Solved

filter only by one character

Posted on 2016-11-21
4
19 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 31

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 31

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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 (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

757 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

21 Experts available now in Live!

Get 1:1 Help Now