【发布时间】:2016-09-27 09:00:46
【问题描述】:
我有图书馆数据库,我正在尝试将大多数借用的标题分配给每年,例如
2015 - The Great Gatsby
2014 - Da vinci code
2013 - Harry Potter
....
我试过了,但我不确定
select to_char(borrow_date,'YYYY'),title_name
from k_title
join k_book
using(title_id)
join k_rent_books
using(book_id)
group by to_char(borrow_date,'YYYY'),title_name
having count(title_id) = (
select max(cnt) FROM(select count(title_name) as cnt
from k_title
join k_book
using(title_id)
join k_rent_books
using(book_id)
group by title_id,title_name,to_char(borrow_date,'YYYY')));
我只有 3 个结果
2016 - Shogun
2006 - The Revolt of Mamie Stover
1996 - The Great Gatsby
我会很高兴得到任何帮助:)
【问题讨论】: