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 |
|
chinlax
Starting Member
30 Posts |
Posted - 2011-09-29 : 00:01:30
|
| Hi all, I am quite new to SQL SERVER 2008, i am learning all the basic queries,can any one help me out in solving the below problem.select top 1 student from each Class in a table. Table Columns are ClassName | StudentName | AggregateofMarksThanks, |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-29 : 00:06:19
|
| can we see what you tried till now?I can give you hintRead about ROW_NUMBER() function and PARTITION BY in books online.Try it out and post if you face any issues so that we can help you out------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
chinlax
Starting Member
30 Posts |
Posted - 2011-09-29 : 05:47:15
|
| Hi,Ok let explain , how much i have worked with, the question is select top 1 student from each Class in a table. Table Columns are ClassName | StudentName | AggregateofMarksSo what did i do is, i created two tables named Class and MarksClass Table has two columns->class name, student nameMarks Table has two columns->Class name, Aggregate Marksso how do i get the topper in each class, and my question is how do get highest marks, from each class having only aggregate marks of each class.Can any one help me out..............Thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-29 : 07:58:55
|
| nope. the table design itelf is wrong. why marks table is having classname? ho can you relate marks to a class? it should be related to student instead. the best way to design it will be having seperate table for student,class and marks. marks will have details of student (studentid) and course/class------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|