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 those customer names that have three names and display the * symbol in
place of the
first name as follows:
CUST NAME
———————*** De Haan
**** Manuel Urman
Which two queries give the required output? (Choose two.)
A.
SELECT LPAD(SUBSTR(cust_name,INSTR(cust_name,’ ‘)),LENGTH(cust_name),’*’) “CUST
NAME” FROM customers
WHERE INSTR(cust_name, ‘ ‘,1,2)<>0;
B.
SELECT LPAD(SUBSTR(cust_name,INSTR(cust_name,’ ‘)),LENGTH(cust_name),’*’) “CUST
NAME” FROM customers
WHERE INSTR(cust_name, ‘ ‘,-1,2)<>0;
C.
SELECT LPAD(SUBSTR(cust_name,INSTR(cust_name,’ ‘)),LENGTH(cust_name)-INSTR(cust_name,”),’*’) “CUST NAME”
FROM customers
WHERE INSTR(cust_name, ‘ ‘,-1,-2)<>0;
D.
SELECT LPAD(SUBSTR(cust_name,INSTR(cust_name,’ ‘)),LENGTH(cust_name)-INSTR(cust_name,’ ‘),’*’) “CUST NAME”
FROM customers
WHERE INSTR(cust_name, ‘ ‘,1,2)<>0 ;
can someone explain …
SELECT last_name, LPAD(SUBSTR(last_name, INSTR(last_name,’ ‘)),LENGTH(last_name),’*’) from employees where last_name like ‘%De %’;
it is clearer here:
select LPAD(SUBSTR(last_name, 3),7,’*’) from employees where last_name like ‘%De %’;