Answer the question
In order to leave comments, you need to log in
How to compose SQL query with COUNT?
There are 2 tables in the database: authors and docs with fields (id, name) and (id, title, author).
How to make a query that would display the fields: author - the number of his documents?
if the document does not have an author, then display the number of such documents
Something like:
Vasya 15
Petya 10
Lena 0
null 50
Answer the question
In order to leave comments, you need to log in
select au.name, count(docs.id)
from docs
left join authors au on au.id = docs.author
group by au.name
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question