I'm having difficulty understand the following query:
SELECT cust_city, COUNT(cust_last_name)
FROM customers
WHERE cust_credit_limit > 1000
GROUP BY cust_city
HAVING AVG(cust_credit_limit) BETWEEN 5000 AND 6000
According to my exam prep, this will run successfully without errors, though I don't understand why.
Doesn't the AVG(cust_credit_limit) also need to be included in with the rest of the fields for this to work properly?
It would be greatly appreciated if someone could explain this better to me.
Thanks,
Sean