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:
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.
select FISRT_NAME from customer where upper(FISRT_NAME) between ‘A’ and ‘Z’
select FISRT_NAME from customer where upper(FISRT_NAME) like ‘P%’ or upper(FISRT_NAME) like ‘S%’
both Query give same answer. So answer will be C
no, Ans A right. If it is written like Between ‘A’ and ‘D’ then it will work.
it means it will search for A ,B,C not for D
Your answer is only partially right.
The between operator is equivalent to >= AND ‘C’
The between operator is equivalent to >= AND ‘C’
The between operator is equivalent to greater than AND lower than, but inequality expressions on string make it that C will be the first in the sort between, for example, ‘C’ and ‘Charles’:
WITH d AS (SELECT ‘Anton’ str FROM DUAL
UNION
SELECT ‘Baudelaire’ str FROM DUAL
UNION
SELECT ‘Charles’ str FROM DUAL
UNION
SELECT ‘C’ str FROM DUAL)
SELECT *
FROM d
WHERE UPPER (str) BETWEEN ‘A’ AND ‘C’
——
STR
Anton
Baudelaire
C
However Charles is missing because ‘Charles’ > ‘C’
Thank you JB – good answer !