Modify the query select \'John Smith\' from DUAL; . This time, use the SUBSTR fu
ID: 3937317 • Letter: M
Question
Modify the query select 'John Smith' from DUAL;. This time, use the SUBSTR function to extract a substring that represents your last name from the text string 'your_first_name your_last_name'. Assume you know the number of characters you need to extract.
Modify the query select 'John Smith' from DUAL; . This time, use the INSTR and SUBSTR functions to extract a substring that represents your first name from the text string 'your_first_name your_last_name'. Assume you do not know the number of characters to extract.
Modify the query select 'John Smith' from DUAL; . This time, use the INSTR, SUBSTR, and LENGTH functions to extract a substring that represents your last name from the text string 'your_first_name your_last_name'. Assume you do not know the number of characters you need to extract.
Explanation / Answer
1. SUBSTR function to extract the last name
select SUBSTR('John Smith', 6,10) from DUAL;
2. INSTR and SUBSTR functions to extact the first name
select SUBSTR('John Smith', 1,INSTR('John Smith', ' ',1,1)) from DUAL;
3.INSTR ,SUBSTR and LENGTH functions to extact the first name
select SUBSTR('John Smith',INSTR('John Smith', ' ',1,1),LENGTH('John Smith')) from DUAL;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.