1、原題
ide
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 first query gives the correct result.
B. Only the second query gives the correct result
C. Both execute successfully and give the same result.
D. Both execute successfully but do not give the required result.
答案:A函數
我的理解:
ui
題目第一個條件,要求返回字母A,B,C開頭的客戶名,查詢二沒有返回符合要求的結果,緣由解釋竟然有多種理解。根據我的理解,第二個查詢返回的是以A和B開頭(包括大小寫!)的全部和單字母C(包括 大小寫C)的用戶名。lua
其實這個題我以爲都有點問題,既然只是判斷首字母,那按慣例就不用UPPER函數,由於首字母按慣例已是大寫了,(這裏用INITCAP不是更好理解?),那用了UPPER函數,是否是意味着還要返回小寫字母a、b、c開頭的姓名呢?(表中也沒有說明該字段限定必定要用大寫字母開頭呀,慣例總不能直接默認了吧)而題幹好像只是要求大寫字母開頭的,用了UPPER查詢判斷的又如何只返回大寫字母開頭的呢??除非還有另一種解釋,沒加雙引號的ABC字母表示是大寫和小字的,而加了雙引號都表示只包含大寫??spa