Reputation: 15
I have 2 tables linked with OneToMany. Table books and table authors. Each author has many books. I want to fetch a list of books, but for each author, only 10 books.
How to achieve that?
Thanks for any help
Upvotes: 0
Views: 38
Reputation: 48770
You can use ROW_NUMBER()
for example:
select *
from (
select *, row_number() over(partition by author_id order by title) as rn
from book
) x
where rn <= 10
Upvotes: 1