By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,197 Members | 977 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,197 IT Pros & Developers. It's quick & easy.

not single- group group function

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.