0
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 つのテーブルがあります。本、著者、執筆者。その著者が何冊の本を書いたかを調べる必要があります。サブクエリは必要ですか?

4

1 に答える 1

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;

列名が正しくないように感じますが

于 2013-04-19T22:47:03.970 に答える