SELECT a.author_num, a.author_last, COUNT(w.book_code)
FROM book.book b, book.author a, book.wrote w
WHERE (b.book_code=w.book_code and w.author_num=a.author_num)
ORDER BY a.author_last DESC;
我有3张桌子;书,作者和写作。我需要找到作者写过多少本书。我需要子查询吗?
答案 0 :(得分:0)
您可以使用GROUP BY
SELECT a.author_num, a.author_last, COUNT(w.book_code)
FROM book.book b, book.author a, book.wrote w
WHERE (b.book_code=w.book_code and w.author_num=a.author_num)
GROUP BY a.author_num, a.author_last
ORDER BY a.author_last DESC;
虽然我觉得你的专栏名称不是很正确