77. 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
Answer: B
答案解析:
此为嵌套函数,由里到外可知:
LENGTH(cust_city)=
LENGTH('Paris'
)=5
SUBSTR(cust_city,-5,2)=从右往左第5个,在顺着输出2个字符,即Pa
UPPER(
Pa)=PA
INITCAP(cust_first_name ' ' UPPER(SUBSTR(cust_city,-LENGTH(cust_city),2)))=INITCAP('ABIGAIL' '' 'PA')=Abigail Pa
即选B。
本文解析了一个具体的SQL查询案例,展示了如何使用嵌套函数处理字符串数据,包括INITCAP、UPPER和SUBSTR等函数的用法。
1823

被折叠的 条评论
为什么被折叠?



