Subqueries in FROM clause

Subqueries in FROM - 1

Let’s say students have to read all the books that exist for the course they are enrolled in. Write a query to display student’s name, name of the course and the number of books they have to read, for each student. Set the headers for the respective columns as student, course and numberOfBooks.


  1. Skip the students who don’t have a course, or don’t have a valid course (Think JOIN vs LEFT JOIN)

  2. Do not skip the students who are enrolled in courses which have no books belonging to them. Make sure 0 is shown in numberOfBooks for such students. (Again, think JOIN vs LEFT JOIN)