您好,登錄后才能下訂單哦!
一、原題
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
個人理解:
題目第一個條件,要求返回字母A,B,C開頭的客戶名,查詢二沒有返回符合要求的結果,原因解釋居然有多種理解。根據個人理解,第二個查詢返回的是以A和B開頭(包括大小寫?。┑乃泻?span >單字母C(包括 大小寫C)的用戶名。
其實這個題我覺得都有點問題,既然只是判斷首字母,那按慣例就不用UPPER函數(shù),因為首字母按慣例已經是大寫了,(這里用INITCAP不是更好理解?),那用了UPPER函數(shù),是不是意味著還要返回小寫字母a、b、c開頭的姓名呢?(表中也沒有說明該字段限定一定要用大寫字母開頭呀,慣例總不能直接默認了吧)而題干好像只是要求大寫字母開頭的,用了UPPER查詢判斷的又如何只返回大寫字母開頭的呢??除非還有另外一種解釋,沒加雙引號的ABC字母表示是大寫和小字的,而加了雙引號都表示只包含大寫??
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。