I want to show the loans which are borrowed the least. This is a case where two loans are tied in the smallest number of borrowers.
Loan:
no | type
------------
L1 | house
L2 | student
L3 | car
Borrower ('num' is foreign key to 'no'):
name | num
----------
A | L1
A | L1
A | L2
A | L3
SELECT loan.type
FROM loan, borrower
WHERE loan.no = b.num
AND loan.type = (SELECT MIN(type) from loan)
GROUP BY loan.type
This should produce student
and car
but for now it's just giving me one of them. How should I modify my query to solve this?
Aucun commentaire:
Enregistrer un commentaire