kago
kago

Reputation: 47

using count query in sql

How could I write an SQL that will display authors and a total number of their publications with a sub query included in my SELECT STATEMENT but this is what I have

enter image description here

Upvotes: 2

Views: 45

Answers (1)

Teja
Teja

Reputation: 13524

SELECT a.auth_name,COUNT( p.pub_title ) AS count_of_publications 
  FROM Author a
LEFT JOIN
       Wrote w
    ON a.auth_id = w.auth_id
LEFT JOIN 
       Publication p
    ON w.pub_id = p.pub_id
GROUP BY a.auth_name;      

Upvotes: 1

Related Questions