I'm supposed to put through a query that returns the document(s) that is(are) the most borrowed. I would have to compare the copy#'s to see what document_title has the most copy# that have a copy_status of 'borrowed'. How exactly would I do this in SQL?
So far I have the following:
SELECT D.document_title, COUNT(*) as "Times borrowed"
FROM Document D, Borrowing B
WHERE D.`document#` = B.`document#`
GROUP BY D.document_title
ORDER BY COUNT(*) DESC LIMIT 1
This gives me the highest borrowed document, but if there were two I wouldn't see that because of the limit. Is there anyway to alter this to show which document(s) is(are) the most borrowed?