Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想做一个查询,显示一个会员租用的电影数量最多,它还应该显示会员的名字。
这就是我所拥有的。
SELECT FIRST, LAST AS, COUNT(mm_rental.member_id) AS "MAXIMUM MOVIES" FROM mm_member, mm_rental WHERE mm_rental.member_id = mm_member.member_id;
但它不起作用。有人可以帮忙吗?
由于COUNT是一个聚合函数,因此您应该在查询中使用GROUP BY。
你应该使用JOIN语法。
更多:请使用 ANSI 连接语法
SELECT [FIRST], [LAST], COUNT(mm_rental.member_id) AS "MAXIMUM MOVIES" FROM mm_member JOIN mm_rental ON mm_rental.member_id = mm_member.member_id group by [FIRST], [LAST];