not single- group group function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • moon

    not single- group group function

    Hi all,
    Im trying to execute this statement in SQL Plus but am getting the
    error not a single-group group function. My code is below. To explain
    what Im trying to get at, I want to return the total grade for g.grade
    that has been multiplied by its appropriate weight that it carries
    towards the total grade.


    SELECT g.section_id, g.student_id, g.grade_type_co de,
    SUM((AVG(g.grad e)*30/100+AVG(g.grade )
    *20/100+AVG(g.grade )*20/100+AVG(g.grade )*10/100+AVG(g.grade )*20/100))
    FROM grade g, grade_type_weig ht gtw
    WHERE g.student_id = 270
    AND g.section_id = gtw.section_id
    AND g.grade_type_co de = gtw.grade_type_ code
    GROUP BY g.section_id, g.student_id,
    g.grade_type_co de
    Any help is greatly appreciated:>
    Moon
  • SoulSurvivor

    #2
    Re: not single- group group function

    You will have to group by g.grade_type_co de as well
    GROUP BY g.section_id, g.student_id, g.grade_type_co de
    M

    emtun@yahoo.com (moon) wrote in message news:<f4ff74b8. 0404251918.4e1c 0146@posting.go ogle.com>...
    Hi all,
    Im trying to execute this statement in SQL Plus but am getting the
    error not a single-group group function. My code is below. To explain
    what Im trying to get at, I want to return the total grade for g.grade
    that has been multiplied by its appropriate weight that it carries
    towards the total grade.
    >
    >
    SELECT g.section_id, g.student_id, g.grade_type_co de,
    SUM((AVG(g.grad e)*30/100+AVG(g.grade )
    *20/100+AVG(g.grade )*20/100+AVG(g.grade )*10/100+AVG(g.grade )*20/100))
    FROM grade g, grade_type_weig ht gtw
    WHERE g.student_id = 270
    AND g.section_id = gtw.section_id
    AND g.grade_type_co de = gtw.grade_type_ code
    GROUP BY g.section_id, g.student_id,
    g.grade_type_co de
    Any help is greatly appreciated:>
    Moon

    Comment

    • Ed prochak

      #3
      Re: not single- group group function

      emtun@yahoo.com (moon) wrote in message news:<f4ff74b8. 0404251918.4e1c 0146@posting.go ogle.com>...
      Hi all,
      Im trying to execute this statement in SQL Plus but am getting the
      error not a single-group group function. My code is below. To explain
      what Im trying to get at, I want to return the total grade for g.grade
      that has been multiplied by its appropriate weight that it carries
      towards the total grade.
      >
      >
      SELECT g.section_id, g.student_id, g.grade_type_co de,
      SUM((AVG(g.grad e)*30/100+AVG(g.grade )
      *20/100+AVG(g.grade )*20/100+AVG(g.grade )*10/100+AVG(g.grade )*20/100))
      FROM grade g, grade_type_weig ht gtw
      WHERE g.student_id = 270
      AND g.section_id = gtw.section_id
      AND g.grade_type_co de = gtw.grade_type_ code
      GROUP BY g.section_id, g.student_id,
      g.grade_type_co de
      Any help is greatly appreciated:>
      Moon
      The error is due to the nesting of the functions, I believe. IOW,
      SUM((AVG(... is not allowed.
      Try creating an inline view.

      Why the extra set of parentheses?

      AND, WHY are you computing it this way?
      SUM((AVG(g.grad e)*30/100
      +AVG(g.grade)*2 0/100
      +AVG(g.grade)*2 0/100
      +AVG(g.grade)*1 0/100
      +AVG(g.grade)*2 0/100))

      Isn't that the same as SUM(AVG(g.grade )) ????
      (I don't think my math is that rusty, or is it??)

      Ed

      Comment

      • Minesh

        #4
        Re: not single- group group function

        Hi,

        Try this

        SElECT a.section_id , a.student_id , a.grade_type_co de , SUM(a.averageco l) FROM
        ( SELECT g.section_id, g.student_id, g.grade_type_co de,
        (AVG(g.grade)*3 0/100+AVG(g.grade )
        *20/100+AVG(g.grade )*20/100+AVG(g.grade )*10/100+AVG(g.grade )*20/100) avaragecol
        FROM grade g, grade_type_weig ht gtw
        WHERE g.student_id = 270
        AND g.section_id = gtw.section_id
        AND g.grade_type_co de = gtw.grade_type_ code
        GROUP BY g.section_id, g.student_id,
        g.grade_type_co de ) a
        Group by a.section_id , a.student_id , a.grade_type_co de



        emgee74@yahoo.c o.uk (SoulSurvivor) wrote in message news:<1ccd66a6. 0404270127.1006 b716@posting.go ogle.com>...
        You will have to group by g.grade_type_co de as well
        >
        GROUP BY g.section_id, g.student_id, g.grade_type_co de
        >
        M
        >
        emtun@yahoo.com (moon) wrote in message news:<f4ff74b8. 0404251918.4e1c 0146@posting.go ogle.com>...
        Hi all,
        Im trying to execute this statement in SQL Plus but am getting the
        error not a single-group group function. My code is below. To explain
        what Im trying to get at, I want to return the total grade for g.grade
        that has been multiplied by its appropriate weight that it carries
        towards the total grade.


        SELECT g.section_id, g.student_id, g.grade_type_co de,
        SUM((AVG(g.grad e)*30/100+AVG(g.grade )
        *20/100+AVG(g.grade )*20/100+AVG(g.grade )*10/100+AVG(g.grade )*20/100))
        FROM grade g, grade_type_weig ht gtw
        WHERE g.student_id = 270
        AND g.section_id = gtw.section_id
        AND g.grade_type_co de = gtw.grade_type_ code
        GROUP BY g.section_id, g.student_id,
        g.grade_type_co de
        Any help is greatly appreciated:>
        Moon

        Comment

        Working...