0
我不確定標題是否對應於我的問題,但這是我能描述它的最好方法。SQL - HAVING與遞歸語句
我想知道是否有理論上可以在having子句中使用遞歸語句進行查詢。例如:
SELECT a_name
FROM (
SELECT Author.id as a_id, Author.name as a_name, COUNT (*) as science_fiction_per_author
FROM Title, Author, Title_tags, Tags, Publication_authors, Publication, Publication_content
WHERE ...
GROUP BY a_id
HAVING science_fiction_per_author = MAX(science_fiction_per_author)
);
這是不可能的。你可以用'COUNT(*)'替換左邊的'science_fiction_per_author',但是你不能把它放在像MAX(COUNT(*))'這樣的另一個聚合函數中。 –
你正在使用哪個DBMS –
另外,你應該避免使用[舊式'JOIN'語法](http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick -using-old-style-joins.aspx) –