QuestionQ71

VerifiedUsing Single-Row Functions to Customize Output

Examine the data in the CUST_NAME column of the CUSTOMERS table.

CUST_NAME  
---------------------  
Lex De Haan  
Renske Ladwig  
Jose Manuel Urman  
Jason Mallin  

You want to extract only customer names that contain three names and replace the first name with *, as follows:

CUST NAME  
---------------------  
*** De Haan  
**** Manuel Urman  

Which two queries produce the required output?

Choose two
Explanation

SUBSTR(cust_name, INSTR(cust_name, ' ')) retains the first space and all following name parts. LPAD to the full original name length fills the removed first-name characters with asterisks. Testing for a second space either from the beginning or by finding the second space while searching backward selects exactly the three-name values.

Learn more

Community Discussion

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