Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
nitzanma
Starting Member
4 Posts |
Posted - 2012-12-31 : 06:31:52
|
i have 4 columns:User IDSubject (of a question)Question IDQuestion Gradei.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 subjectmeaning that the output will be:UserID Subject AverageGradehow can i do that?thank you very much! |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2012-12-31 : 09:23:43
|
So what have you tried? |
|
|
nitzanma
Starting Member
4 Posts |
Posted - 2012-12-31 : 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
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-12-31 : 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. JimEveryday I learn something that somebody else already knew |
|
|
nitzanma
Starting Member
4 Posts |
Posted - 2013-01-01 : 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
885 Posts |
Posted - 2013-01-01 : 10:01:40
|
SELECT [User ID],[Subject],AVG([Question Grade]) AS Avg_GradeFROM yourResultTableGROP BY [User ID],[Subject]--------------------------http://connectsql.blogspot.com/ |
|
|
nitzanma
Starting Member
4 Posts |
Posted - 2013-01-02 : 03:28:02
|
quote: Originally posted by lionofdezert SELECT [User ID],[Subject],AVG([Question Grade]) AS Avg_GradeFROM yourResultTableGROP 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 bythanks again (: |
|
|
|
|
|
|
|