1. Learn
  2. /
  3. Courses
  4. /
  5. Querying a PostgreSQL Database in Java

Connected

Exercise

Summarizing the data

You are a developer for the Metropolitan Public Library. The head librarian has requested a new feature for the online catalog: displaying rating statistics for each book to help patrons make informed reading choices. Currently, the system stores individual reviews in the book_reviews table; however, there's no way to view the total number of reviews a book has received or its average rating.

Your task is to write a query that summarizes review data by calculating the total number of reviews and the average rating for each book.

Instructions

100 XP
  • Complete the query to count the number of reviews and calculate the average rating.
  • Group the results by book_id to get statistics for each book.