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.

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.

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

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:



Leave a Reply 8

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


farhan

farhan

I think even B is not correct. It will select names starting with ‘mC’ or ‘mc’ as well which is not what the requirement is

dames

dames

WHERE (SUBSTR(cust_name, INSTR(cust_name,’ ‘)+1,2)) IN (‘MC’,’Mc’);

Leandro

Leandro

The answer is based on the data shown. It’s correct.

Giovanni Amorim

Giovanni Amorim

B is the correct answer. The INITCAP function that is the outermost function will transform the name “MC” in “Mc”. Soon it will be possible to search for ‘Mc’ when using the LIKE function.

lbien

lbien

B is correct

Mr. T

Mr. T

B is not correct by 100% – but it’s the best answer… 😉

The Tuk

The Tuk

SQL> select substr(cust_name, instr(cust_name,’ ‘)+1)
2 from cust_q46
3 where initcap(substr(cust_name, instr(cust_name, ‘ ‘)+1)) like ‘Mc%’ ;

SUBSTR(CUST_NAME,INSTR(CUST_NAME,”)+1)
——————————————————————————–
McCain
MCEwen

The Tuk

The Tuk

SQL> select substr(cust_name, instr(cust_name,’ ‘)+1)
2 from cust_q46
3 where substr(cust_name, instr(cust_name, ‘ ‘)+1) like initcap(‘MC%’) ;

SUBSTR(CUST_NAME,INSTR(CUST_NAME,”)+1)
——————————————————————————–
McCain