0
The output is not matching the code.
You are working on the library database, which contains the Books and Authors tables. Columns of the Books table: id, name, year, author_id. Columns of the Authors table: id, name. Write a query to get the author names and the number of books they have in the Books table. Note that some authors do not have any books associated with them. In this case, the result needs to include their names and have 0 as the count. The count column should be called books in the result. SELECT Authors.name AS author_name, COALESCE(COUNT(Books.id), 0) AS books FROM Authors LEFT JOIN Books ON Authors.id = Books.author_id GROUP BY Authors.id, Authors.name;
4 Antworten
+ 4
Div Anand ,
it helps a lot if your post / question has some more information which tutorial / lesson / exercise you are talking about (if it is a sololearn exercise).
[edited]:
sql intermediate - working with data - joins - lesson takeaways
code coach: number of books
+ 4
Div Anand ,
i found these issues:
> autors name col. should not be renamed
> grouping should be only by autors name
> missing order statement according description
+ 3
Does the task ask you to rename the column?
What about the sorting order?
0
What is the answer of this question?