To Get Certification, Click Here: bitly.ws/PXXy Use coupon "KZbin12" to get ‘’FLAT 12%’’ OFF at Checkout.
@simpleepic4 жыл бұрын
I think here you missed GROUP BY sir! So the complete one will be like this : SELECT d.cname, AVG(a.bal) FROM Customer AS c, Account AS a, Depositor AS d WHERE c.cname = d.cname AND a.ano = d.ano AND c.ccity LIKE "Pune" GROUP BY d.cname HAVING COUNT(DISTINCT d.ano) >= 3; Instead of using Cartesian product we can also use JOINS : SELECT d.cname, AVG(a.bal) FROM Depositor AS d JOIN Customer AS c ON c.cname = d.cname JOIN Account AS a ON a.ano = d.ano WHERE c.ccity LIKE "Pune" GROUP BY d.cname HAVING COUNT(DISTINCT d.ano) >= 3; Hope this will be helpful for someone :3
@adi-hk4hb6 жыл бұрын
In the last question i think there must be (GROUP BY d.cname)
@TERKO625 жыл бұрын
do you need for the last question, also the account table? Cant you just simply take customer and depositor to check if the customer has more acount_number then 3? do not need the account then if you want to use just the one information that they have in common.
@josephhakim42124 жыл бұрын
There is a mistake in the last question , you must have GROUP BY d.cname , this way you will return the average for each customer name, The current query that you have in the video will not work in case you have over 1 customer name since the avg(bal) will only return 1 tuple.