【OCP 12c】最新CUUG OCP-071考試題庫(61題)
View the Exhibit and examine the structure of the CUSTOMERS table.
You want to generate a report showing the last names and credit limits of all customers whose last names start with A, B, or C, and credit limit is below 10,000.
Evaluate the following two queries:
SQL> SELECT cust_last_name, cust_credit_limit FROM customers
WHERE (UPPER(cust_last_name) LIKE ‘A%‘ OR
UPPER(cust_last_name) LIKE ‘B%‘ OR
UPPER(cust_last_name) LIKE ‘C%‘)
AND cust_credit_limit < 10000;
SQL> SELECT cust_last_name, cust_credit_limit FROM customers
WHERE UPPER(cust_last_name) BETWEEN ‘A‘ AND ‘C‘
AND cust_credit_limit < 10000;
Which statement is true regarding the execution of the above queries?
A) Only the second query gives the correct result.
B) Only the first query gives the correct result.
C) Both execute successfully but do not give the required result.
D) Both execute successfully and give the same result.
Answer:B
(解析:驗證結果發現第二 sql 語句不能返回 C 開頭的名字,如果改為 BETWEEN ‘A‘ AND ‘D‘,則查出來的結果與第一個語句一樣,而且語句簡潔,答案更好。
經過測試發現,如果數據類型是 number 的,則 between 800 and 3000 的結果包含 3000 的值:
SQL> select sal from emp where sal between 800 and 3000;
SAL
800
1600)
1500
950
3000
但是如果是字符型的,則不包含between ‘A‘ AND ‘C‘後面的 C :
SQL> select ename from emp where ename between ‘A‘ AND ‘C‘;
ENAME
ALLEN
BLAKE
)
【OCP 12c】最新CUUG OCP-071考試題庫(61題)