I am quoting from here :
"You can use the query above as a correlated subquery to find customers who placed at least one sales order with the total value greater than 60K by using the EXISTS operator:
SELECT
customerNumber,
customerName
FROM
customers
WHERE
EXISTS( SELECT
orderNumber, SUM(priceEach * quantityOrdered)
FROM
orderdetails
INNER JOIN
orders USING (orderNumber)
WHERE
customerNumber = customers.customerNumber
GROUP BY orderNumber
HAVING SUM(priceEach * quantityOrdered) > 60000);
" You can paste the code in the editor here to see the results.
Suppose I omit the WHERE
clause in the subquery and the EXISTS
operator returns TRUE
. 1) Then why can't I get the customerNumber
and customerName
of all the customers ? 2) How many times is the EXISTS
operator evaluated ?