OCP-1Z0-051-V9.02-82题

82. 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%');

Answer: B

答案解析:

参考:http://blog.csdn.net/rlhua/article/details/12848395

题意要求:You need to display customers' second names where the second name starts with "Mc" or "MC."

cust_name由first name和second name组成,中间有空格,要求找出second name以"Mc" or "MC."开头

INSTR(cust_name,' ')找出空格的位置,并返回,这个位置之后的second name的开始。

SUBSTR(cust_name, INSTR(cust_name,' ')+1)找出空格+1的之后的字符,即是找出second name的名字。

INITCAP(SUBSTR(cust_name, INSTR(cust_name,' ')+1)) LIKE 'Mc%'  匹配出 LIKE 'Mc%'or "MC“的字符,使用INITCAP,让其匹配。


故答案选B