You need to display customers’ second names where the second name starts with "Mc" or "MC." Which query gives the required output?

Examine the data in the CUST_NAME column of the CUSTOMERS table.
CUST_NAME
————————Renske Ladwig
Jason Mallin
Samuel McCain
Allan MCEwen
Irene Mikkilineni
Julia Nayer
You need to display customers’ second names where the second name starts with “Mc” or “MC.”
Which query gives the required output?

Examine the data in the CUST_NAME column of the CUSTOMERS table.
CUST_NAME
————————Renske Ladwig
Jason Mallin
Samuel McCain
Allan MCEwen
Irene Mikkilineni
Julia Nayer
You need to display customers’ second names where the second name starts with “Mc” or “MC.”
Which query gives the required output?

A.
SELECT SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1)
FROM customers
WHERE INITCAP(SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1))=’Mc’;

B.
SELECT SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1)
FROM customers
WHERE INITCAP(SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1)) LIKE ‘Mc%’;

C.
SELECT SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1)
FROM customers
WHERE SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1) LIKE INITCAP(‘MC%’);

D.
SELECT SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1)
FROM customers
WHERE INITCAP(SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1)) = INITCAP(‘MC%’);



Leave a Reply 4

Your email address will not be published. Required fields are marked *


singh

singh

B

Helter

Helter

help ? : is ans. B for EBCDIC-based platform, and
ans. C(with INITCAP for SUBSTR) for ASCII platforms? , TY

Eamon

Eamon

The answer is B

with customers as(
select ‘Renske Ladwig’ as cust_name from dual UNION
select ‘Jason Mallin’ from dual UNION
select ‘Samuel McCain’ from dual UNION
select ‘Allan MCEwen’ from dual UNION
select ‘Irene Mikkilineni’ from dual UNION
select ‘Julia Nayer’ from dual
)
SELECT SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1)
FROM customers
WHERE INITCAP(SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1)) LIKE ‘Mc%’
/
SUBSTR(CUST_NAME,
—————–
MCEwen
McCain

Eamon

Eamon

by the way my platform is ASCII
🙂