469,602 Members | 1,747 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

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_code,
SUM((AVG(g.grade)*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_weight gtw
WHERE g.student_id = 270
AND g.section_id = gtw.section_id
AND g.grade_type_code = gtw.grade_type_code
GROUP BY g.section_id, g.student_id,
g.grade_type_code
Any help is greatly appreciated:>
Moon
Jul 19 '05 #1
3 15497
You will have to group by g.grade_type_code as well
GROUP BY g.section_id, g.student_id, g.grade_type_code
M

em***@yahoo.com (moon) wrote in message news:<f4**************************@posting.google. 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_code,
SUM((AVG(g.grade)*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_weight gtw
WHERE g.student_id = 270
AND g.section_id = gtw.section_id
AND g.grade_type_code = gtw.grade_type_code
GROUP BY g.section_id, g.student_id,
g.grade_type_code
Any help is greatly appreciated:>
Moon

Jul 19 '05 #2
em***@yahoo.com (moon) wrote in message news:<f4**************************@posting.google. 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_code,
SUM((AVG(g.grade)*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_weight gtw
WHERE g.student_id = 270
AND g.section_id = gtw.section_id
AND g.grade_type_code = gtw.grade_type_code
GROUP BY g.section_id, g.student_id,
g.grade_type_code
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.grade)*30/100
+AVG(g.grade)*20/100
+AVG(g.grade)*20/100
+AVG(g.grade)*10/100
+AVG(g.grade)*20/100))

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

Ed
Jul 19 '05 #3
Hi,

Try this

SElECT a.section_id , a.student_id , a.grade_type_code , SUM(a.averagecol) FROM
( SELECT g.section_id, g.student_id, g.grade_type_code,
(AVG(g.grade)*30/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_weight gtw
WHERE g.student_id = 270
AND g.section_id = gtw.section_id
AND g.grade_type_code = gtw.grade_type_code
GROUP BY g.section_id, g.student_id,
g.grade_type_code ) a
Group by a.section_id , a.student_id , a.grade_type_code

em*****@yahoo.co.uk (SoulSurvivor) wrote in message news:<1c**************************@posting.google. com>...
You will have to group by g.grade_type_code as well
GROUP BY g.section_id, g.student_id, g.grade_type_code


M

em***@yahoo.com (moon) wrote in message news:<f4**************************@posting.google. 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_code,
SUM((AVG(g.grade)*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_weight gtw
WHERE g.student_id = 270
AND g.section_id = gtw.section_id
AND g.grade_type_code = gtw.grade_type_code
GROUP BY g.section_id, g.student_id,
g.grade_type_code
Any help is greatly appreciated:>
Moon

Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by sinister | last post: by
2 posts views Thread by John Dann | last post: by
13 posts views Thread by Kevin Walzer | last post: by
7 posts views Thread by ashley.ward | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.