Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL query to display the length and first 3 characters of ename column in employee table

just as the question can we do something to get the length and first 3 characters of the employee name of one column

Please do not mark as answered or duplicate i have the test tomorrow Advance SQL so I am trying to solve some imp question.. Please answer the problem

thanks again

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use LEN() or LENGTH()(in case of oracle sql) function to get the length of a column.

SELECT LEN(column_name) FROM table_name;

And you can use SUBSTRING or SUBSTR() function to get first three characters of a column.

Ex. SUBSTRING( string, start_position, length );

SELECT SUBSTRING( column_name, 1, 3 ) col_name
FROM table_name;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading