General
cancel
Showing results for 
Search instead for 
Did you mean: 

find emp id that are = or greater than 8 chars

SOLVED
Go to solution
Ratzie
Super Advisor

find emp id that are = or greater than 8 chars

How do I do the where clause for finding emp id that is less that 8 characters
4 REPLIES
Bill Hassell
Honored Contributor

Re: find emp id that are = or greater than 8 chars

I think a bit more information is needed Are your employee ID's in a file like /etc/passwd? By 'clause' are you referring to a shell script or a database? If you're looking for a script to process a flat file, what do the records look like? If it is a database, you'll need to contact your DBA to help define the appropriate SQL statements.


Bill Hassell, sysadmin
Indira Aramandla
Honored Contributor
Solution

Re: find emp id that are = or greater than 8 chars

Hi LHradowy,

You can use the length function to do that.

select empid, col2, col3.....
from table
where length(empid) < 9;




Indira A
Never give up, Keep Trying
Hein van den Heuvel
Honored Contributor

Re: find emp id that are = or greater than 8 chars

Bill,

Our fried LHradowy general posts Oracle based questions.

LHradowy,

Why not simply use the 'length' function?
If the data is padded with spaces (or something else) then remove those first.
For example:

SQL> desc test
Name Null? Type
---------- -------- -----------
TEST VARCHAR2(28)


SQL> select test, length(test), length(rtrim(test)) from test;

TEST LENGTH(TEST) LENGTH(RTRIM(TEST))
-------- ------------ -------------------
abcd 4 4
abcde 5 5
abcdef 6 6
abcd 13 4
abcde 14 5

SQL> select '->'||test||'<-' from test where length(rtrim(test)) < 5;

'->'||TEST||'<-'
--------------------------------
->abcd<-
->abcd <-


Enjoy!... or clarify.
Hein

HvdH Performance Consulting

Ratzie
Super Advisor

Re: find emp id that are = or greater than 8 chars

Perfect