This is a hw question. I want to find the borrowers who took all loans.
Schema:
loan (number (PKEY), type, min_rating)
borrower (cust (PKEY), no (PKEY))
Sample tables (not representative of everything):
number | type | min_rating
------------------------------
L1 | student | 500
L2 | car | 550
L3 | house | 500
L4 | car | 700
L5 | car | 900
cust | no
-----------
Jim | L2
Tom | L1
Tom | L2
Tom | L3
Tom | L4
Tom | L5
Bob | L3
(The answer here will be Tom)
I can simply count the total number of loans and compare the borrower's number of loans to that, but I'm NOT allowed to, for the purposes of this homework and learning.
So I wanted to use double-negation where I first find the borrowers who didn't take all the loans and find borrowers who are not in that set. I want to use nesting with NOT EXISTS but I am not sure where to start.
Aucun commentaire:
Enregistrer un commentaire