| Author |
Topic  |
|
|
nitzanma
Starting Member
4 Posts |
Posted - 12/31/2012 : 06:31:52
|
i have 4 columns: User ID Subject (of a question) Question ID Question Grade
i.e. i got users that solve questions in several subjucts - and all their achievements are documented in the db.
I would like to present user's average grade in each subject
meaning that the output will be: UserID Subject AverageGrade
how can i do that?
thank you very much! |
|
|
sodeep
Flowing Fount of Yak Knowledge
USA
7173 Posts |
Posted - 12/31/2012 : 09:23:43
|
| So what have you tried? |
 |
|
|
nitzanma
Starting Member
4 Posts |
Posted - 12/31/2012 : 13:18:09
|
quote: Originally posted by sodeep
So what have you tried?
i have very basic knowledge, i know to perform quite simple queries, and here i know it probably needs nested queries, but i just don't have an idea how to begin.
if it wasn't clear - each questionGrade belongs to QuestionID. and each QuestionID belongs to a Subject (represented by int) |
 |
|
|
jimf
Flowing Fount of Yak Knowledge
USA
2868 Posts |
Posted - 12/31/2012 : 13:34:49
|
Your question was clear, it just looks like a homework question, and most people here are reluctant to do other people's homework for them. However, if you give it your best shot first, people here are very willing to help you along.
Jim
Everyday I learn something that somebody else already knew |
 |
|
|
nitzanma
Starting Member
4 Posts |
Posted - 01/01/2013 : 03:45:57
|
this is no homework. it might sound like that, because i tried writing it the simplest way i could. I'm doing a research, that includes some data mining, but mostly in a basic way. I'm willing to make this query work, so I can take it to Weka, and find some interesting association rules.
your help will be very appreciated. best regards. |
 |
|
|
lionofdezert
Aged Yak Warrior
Pakistan
864 Posts |
Posted - 01/01/2013 : 10:01:40
|
SELECT [User ID],[Subject],AVG([Question Grade]) AS Avg_Grade FROM yourResultTable GROP BY [User ID],[Subject]
-------------------------- http://connectsql.blogspot.com/ |
 |
|
|
nitzanma
Starting Member
4 Posts |
Posted - 01/02/2013 : 03:28:02
|
quote: Originally posted by lionofdezert
SELECT [User ID],[Subject],AVG([Question Grade]) AS Avg_Grade FROM yourResultTable GROP BY [User ID],[Subject]
-------------------------- http://connectsql.blogspot.com/
thanks a lot! i couldn't figure this is so simple! i was positive that it will do average to all records. now i understand the use in group by
thanks again (: |
 |
|
| |
Topic  |
|