I have 2 tables; first table Book, having book id and chapters. The second table points having studentid, bookid and hw-points for the students. I need to get results like below tabular format.
Chapter 1 Chapter 2 Chapter 3
Book 1 sum of c1/B1 sum of c2/B1 sum of c2/B1
Book 2 sum of c1/B2 sum of c2/B2 sum of c2/B2
Points-table
id userid BookId homeworkPoints
2 1308 673 250
3 2631 674 200
4 2631 627 175
5 2631 675 50
6 2631 647 50
7 2631 681 50
8 2631 638 50
Book-Table
id Book-Id Chapter-Id
673 1 1
674 1 2
675 1 3
681 2 1
687 2 2
688 2 3