title: COALESCE(SUM(...),0) COALESCE(COUNT(...),0) not working in my code
body: <p>I'm trying to get 0 instead of NULL with COALESCE but it seems like it doesn't work. Here's my code. You can see on the following picture what's the current result.
  <img src="https://i.ibb.co/SN4vyfz/Schermata-2019-02-01-alle-15-44-01.png" alt="result"></p>
  
  <pre><code>CREATE VIEW "PathToGraduation" (student, "totalCredits", "mandatoryLeft", "mathCredits", "researchCredits", "seminarCourses")
  AS  SELECT idnr, "A".credits, "B"."mandatoryLeft", "C"."mathCredits", "D"."researchCredits", "E"."seminarCourses"
       FROM   "Students"
            LEFT OUTER JOIN (
                 SELECT student, COALESCE(SUM(credits),0) AS credits
                 FROM   "PassedCourses"
                 GROUP BY student) AS "A"
                 ON idnr = "A".student
            LEFT OUTER JOIN (
                 SELECT UM.student, COALESCE(COUNT(UM.student),0) AS "mandatoryLeft"
                 FROM  "Students" S, "UnreadMandatory" UM
                 WHERE S.idnr = UM.student
                 GROUP BY UM.student) AS "B"
                 ON idnr = "B".student
            LEFT OUTER JOIN (
                 SELECT PC.student, COALESCE(SUM(PC.credits),0) AS "mathCredits"
                 FROM "PassedCourses" PC, "Classified" CL
                 WHERE CL.course = PC.course AND CL.classification = 'math'
                 GROUP BY "student") AS "C"
                 ON idnr = "C".student
            LEFT OUTER JOIN (
                 SELECT PC.student, COALESCE(SUM(PC.credits),0) AS "researchCredits"
                 FROM "PassedCourses" PC, "Classified" CL
                 WHERE CL.course = PC.course AND CL.classification = 'research'
                 GROUP BY "student") AS "D"
                 ON idnr = "D".student
            LEFT OUTER JOIN (
                 SELECT PC.student, COALESCE(COUNT(PC.course),0) AS "seminarCourses"
                 FROM "PassedCourses" PC, "Classified" CL
                 WHERE CL.course = PC.course AND CL.classification = 'seminar'
                 GROUP BY "student") AS "E"
                 ON idnr = "E".student;
  </code></pre>