Solved

filter only by one character

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SAS Email Chart as attachment code 2 290
Tricky SQL question 13 398
compare column value for each row 4 77
Monitor SQL Insert 8 66
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

832 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