0

I am trying to show all authors and how many books they have published, however the below query omits the authors with no books published

SELECT INITCAP(fname), INITCAP(lname), COUNT(*) FROM author JOIN bookauthor USING (authorid) GROUP BY INITCAP(fname), INITCAP(lname);

ReeDfence
  • 41
  • 9

1 Answers1

2

When you use aggregate function you need to add non-aggregate colnums in group by

So add group by on INITCAP(fname), INITCAP(lname)

SELECT INITCAP(fname), INITCAP(lname), COUNT(*)
FROM author 
JOIN bookauthor USING (authorid)
GROUP BY INITCAP(fname), INITCAP(lname)
D-Shih
  • 44,943
  • 6
  • 31
  • 51