Author |
Topic |
hyderja
Starting Member
5 Posts |
Posted - 2013-04-14 : 23:22:15
|
Help I only have approx. 163 hairs left on my head SELECT name "Exam Name", AVG(score) "Average Score", COUNT (exam_id) "Number of Attempts" FROM exam JOIN student_exam USING (exam_id) WHERE test_date >= '01-JAN-2006' GROUP BY exam_id ORDER BY exam_id ;getting "not a group by expression"What I am doing wrong? |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-14 : 23:56:55
|
Try these two queries.. Let us know which one is suitable for your data?-- If you have unique exam name per exam_idSELECT exam_id, name "Exam Name", AVG(score) "Average Score",COUNT (exam_id) "Number of Attempts"FROM examJOIN student_examUSING (exam_id)WHERE test_date >= '01-JAN-2006'GROUP BY exam_id, nameORDER BY exam_id;-- Another way in the case multiple exam names per exam_idSELECT name "Exam Name", AVG(score) "Average Score",COUNT (exam_id) "Number of Attempts"FROM examJOIN student_examUSING (exam_id)WHERE test_date >= '01-JAN-2006'GROUP BY nameORDER BY exam_id; |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-15 : 02:13:11
|
USING is not a T-SQL statement.are you using SQL Server? ALso in any case grouping by examid will give you a row per exam which will defeat the whole purpose of grouping so i think what you may want is grouping on name------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
 |
|
hyderja
Starting Member
5 Posts |
Posted - 2013-04-15 : 08:21:10
|
quote: Originally posted by bandi Try these two queries.. Let us know which one is suitable for your data?-- If you have unique exam name per exam_idSELECT exam_id, name "Exam Name", AVG(score) "Average Score",COUNT (exam_id) "Number of Attempts"FROM examJOIN student_examUSING (exam_id)WHERE test_date >= '01-JAN-2006'GROUP BY exam_id, nameORDER BY exam_id; This works but it adds a exam_id column which I do not want in my display.-- Another way in the case multiple exam names per exam_idSELECT name "Exam Name", AVG(score) "Average Score",COUNT (exam_id) "Number of Attempts"FROM examJOIN student_examUSING (exam_id)WHERE test_date >= '01-JAN-2006'GROUP BY nameORDER BY exam_idThis one I am still getting the SQL Error: ORA-00979: not a GROUP BY expression
|
 |
|
hyderja
Starting Member
5 Posts |
Posted - 2013-04-15 : 08:21:46
|
quote: Originally posted by visakh16 USING is not a T-SQL statement.are you using SQL Server? ALso in any case grouping by examid will give you a row per exam which will defeat the whole purpose of grouping so i think what you may want is grouping on nameI am using SQL developer.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
|
 |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-04-15 : 08:25:10
|
This forum is for Microsoft SQL Server. If you are using Oracle SQL Developer, you would get faster and better responses at an Oracle forum. |
 |
|
hyderja
Starting Member
5 Posts |
Posted - 2013-04-15 : 21:58:44
|
Next problemHow would this be created>Create a view called current_enrollment. The view should display the number of students currently enrolled for each gradelevel (in grade level order). (Note: the grade levels only range from 1–8) |
 |
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2013-04-15 : 23:34:28
|
quote: Originally posted by James K This forum is for Microsoft SQL Server. If you are using Oracle SQL Developer, you would get faster and better responses at an Oracle forum.
^ This |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-16 : 00:40:07
|
quote: Originally posted by hyderja Next problemHow would this be created>Create a view called current_enrollment. The view should display the number of students currently enrolled for each gradelevel (in grade level order). (Note: the grade levels only range from 1–8)
--This is in SQL Server...CREATE VIEW current_enrollmentAS SELECT Grade_Level, COUNT(student_id) NoOfStudents FROM TableName WHERE Grade_Level BETWEEN 1 AND 8 GROUP BY Grade_Level Try to post Oracle questions in Oracle forums( that is the way to get quick responses from Oracle people).... This is SQL Server Forum..--Chandu |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-16 : 00:41:30
|
quote: Originally posted by hyderja
quote: Originally posted by bandi Try these two queries.. Let us know which one is suitable for your data?-- If you have unique exam name per exam_idSELECT exam_id, name "Exam Name", AVG(score) "Average Score",COUNT (exam_id) "Number of Attempts"FROM examJOIN student_examUSING (exam_id)WHERE test_date >= '01-JAN-2006'GROUP BY exam_id, nameORDER BY exam_id; This works but it adds a exam_id column which I do not want in my display.-- Another way in the case multiple exam names per exam_idSELECT name "Exam Name", AVG(score) "Average Score",COUNT (exam_id) "Number of Attempts"FROM examJOIN student_examUSING (exam_id)WHERE test_date >= '01-JAN-2006'GROUP BY nameORDER BY exam_idThis one I am still getting the SQL Error: ORA-00979: not a GROUP BY expression
--Chandu |
 |
|
hyderja
Starting Member
5 Posts |
Posted - 2013-04-16 : 13:33:47
|
Thanks guys.. |
 |
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-04-17 : 01:32:57
|
quote: Originally posted by hyderja Thanks guys..
Welcome --Chandu |
 |
|
|