OCP 1Z0 051 82

来源:互联网 发布:明星开的淘宝店 编辑:程序博客网 时间:2024/05/01 11:02
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%'); 

substr没有第三个参数时,取指定位置到末尾所有的字符
initcap 把所有单词,首字母大写,其它字母小写
所以A有等值判断不对
C 大小写不一致
D等值判断不对
SQL> SQL> CREATE OR REPLACE VIEW customers(CUST_NAME)  2  AS  3  SELECT 'Renske Ladwig' from dual union all  4  SELECT 'Jason Mallin' from dual union all  5  SELECT 'Samuel McCain' from dual union all  6  SELECT 'Allan MCEwen' from dual union all  7  SELECT 'Irene Mikkilineni' from dual union all  8  SELECT 'Julia Nayer' from dual;View createdSQL> SELECT cust_name,  2         substr(cust_name, instr(cust_name, ' ') + 1) AS sub,  3         initcap(substr(cust_name, instr(cust_name, ' ') + 1)) AS "INITCAP"  4    FROM customers;CUST_NAME         SUB                                INITCAP----------------- ---------------------------------- ----------------------------------Renske Ladwig     Ladwig                             LadwigJason Mallin      Mallin                             MallinSamuel McCain     McCain                             MccainAllan MCEwen      MCEwen                             McewenIrene Mikkilineni Mikkilineni                        MikkilineniJulia Nayer       Nayer                              Nayer6 rows selected

SQL> SELECT substr(cust_name, instr(cust_name, ' ') + 1)  2    FROM customers  3   WHERE initcap(substr(cust_name, instr(cust_name, ' ') + 1)) LIKE 'Mc%';SUBSTR(CUST_NAME,INSTR(CUST_NA----------------------------------McCainMCEwen2 rows selected

Answer: B 
0 0
原创粉丝点击