一、原题
SQL> select SUBSTR('Paris',-LENGTH('Paris'),2) from dual;
SUBS
----
Pa
SQL> SELECT INITCAP('ABIGAIL'|| ' '|| UPPER(SUBSTR('Paris',-LENGTH('Paris'),2))) from dual;
INITCAP('ABIGAIL'||'
--------------------
Abigail Pa
In the CUSTOMERS table, the CUST_CITY column contains the value 'Paris' for the
CUST_FIRST_NAME 'ABIGAIL'.
Evaluate the following query:
SQL> SELECT INITCAP(cust_first_name|| ' '||
UPPER(SUBSTR(cust_city,-LENGTH(cust_city),2)))
FROM customers
WHERE cust_first_name = 'ABIGAIL';
What would be the outcome?
A. Abigail PA
B. Abigail Pa
C. Abigail IS
D. an error message
答案:B
二、题目翻译CUST_FIRST_NAME 'ABIGAIL'.
Evaluate the following query:
SQL> SELECT INITCAP(cust_first_name|| ' '||
UPPER(SUBSTR(cust_city,-LENGTH(cust_city),2)))
FROM customers
WHERE cust_first_name = 'ABIGAIL';
What would be the outcome?
A. Abigail PA
B. Abigail Pa
C. Abigail IS
D. an error message
答案:B
CUSTOMERS表中,CUST_CITY列值为Paris,对应CUST_FIRST_NAME值为ABIGAIL
下面的语句的执行结果是什么?
三、题目解析下面的语句的执行结果是什么?
SUBSTR(cust_city,-LENGTH(cust_city),2),将cust_city(即'Paris')从-5的位置(即右起第五个位置,即左起第一个位置),截取2个字符。
所以,SUBSTR截取的结果是Pa,UPPER转换后为PA,INITCAP是将首字符大写,后为Abigail Pa
所以,SUBSTR截取的结果是Pa,UPPER转换后为PA,INITCAP是将首字符大写,后为Abigail Pa
SQL> select SUBSTR('Paris',-LENGTH('Paris'),2) from dual;
SUBS
----
Pa
SQL> SELECT INITCAP('ABIGAIL'|| ' '|| UPPER(SUBSTR('Paris',-LENGTH('Paris'),2))) from dual;
INITCAP('ABIGAIL'||'
--------------------
Abigail Pa