title: how to use MAX function in case statement under sum expression in oracle sql?
body: <pre><code>  SELECT A.institution,
           A.acad_career,
           A.emplid,
           a.strm,
           NVL(
               SUM(
                   CASE
                       WHEN     A.repeat_candidate IN ('N', 'Y')
                            AND A.CRSE_GRADE_OFF != 'F' THEN
                           MAX(grade_points)
                       ELSE
                           (grade_points)
                   END
                  ),
               0
              )
               AS GPA,
           NVL(SUM(CASE WHEN a.repeat_candidate = 'N' THEN A.UNT_TAKEN END), 0) AS TAKEN,
           a.acad_prog
      FROM ps_stdnt_enrl A, ps_STDNT_CLAS_D_VW B
     WHERE     A.emplid = B.emplid
           AND A.class_nbr = B.class_nbr
           AND A.strm = B.strm
           AND A.acad_career = B.acad_career
           AND a.STDNT_ENRL_STATUS = 'E'
           AND a.emplid LIKE '06381313011%'
  GROUP BY a.emplid,
           a.acad_career,
           a.institution,
           a.acad_prog,
           A.strm
  </code></pre>
  
  <p>This query work fine without max function bt here problems is that student can repeat passed course so at this condition max value is required but its return error not a single group function.</p>