Home > Back-end >  SQL query to display the length and first 3 characters of ename column in employee table
SQL query to display the length and first 3 characters of ename column in employee table

Time:12-28

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

CodePudding user response:

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;

CodePudding user response:

This exact question is covered in detail in many learning sites and modules: https://www.geeksforgeeks.org/sql-query-to-display-the-length-and-first-3-characters-of-ename-column-in-emp-table/

  • Related