Selecting the number of characters from a field?
I'm new to SQL and I'm hoping someone can help me. I need to write an SQL statement to give me the number of users with less than 8 characters in the name. Please help!!!
you will need the length() function then
cursor c1 is select username from dba_users;
fetch c1 into c1_rec;
exit when c1_rec%NOTFOUND;
select getlength(c1_rec.username) into v_len from dual;
Hope this will suffice your requirement.
I'm sorry to say that, Barun, but your script is nothing but bunch of errors.
The sql needed might be something like this:
select count(*) from the_table where length(username)<8;
The whole difference between a little boy and an adult man is the price of toys
Wow! Script doesn't even attempt to solve poster's business specifications. Why would you do it simple and well when you can do it complex and all wrong, isn't it?
Originally Posted by B.B
Ales is spot on correct.
Pablo (Paul) Berzukov
Author of Understanding Database Administration
available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Click Here to Expand Forum to Full Width