QuestionQ172

VerifiedUsing Single-Row Functions to Customize Output

The EMPLOYEES table has these columns:

| Column | Data type |

|---|---|

| EMPLOYEE_ID | NUMBER(4) |

| ENAME | VARCHAR2(25) |

| JOB_ID | VARCHAR2(10) |

Which SQL statement returns the ENAME, the length of ENAME, and the numeric position of the letter "a" in the ENAME column for employees whose ENAME ends with the letter "n"?

Explanation

LENGTH returns a string’s length, INSTR(ENAME, 'a') returns the position of a within ENAME, and SUBSTR(ENAME, -1, 1) returns the last character because a negative starting position counts backward from the end. Comparing that character with n selects names ending in n.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!