|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Top 10 scores - Row Query
I have a database that holds student details in one table and their scores in particular subjects in another. The tables are linked through ID. The subjects table looks like this. (example)
ID Sub1 Sub2 Sub3 Sub4 etc 1 2 4 2 6 2 5 5 1 3 3 7 4 2 5 etc What I need to do is return a students details followed by their top 10 subjects in ascending order. Student 1's results would look like this... Student 1 details Sub1 2 Sub3 2 Sub2 4 Sub4 6 This is driving me insane. Please help. |
|
#2
|
|||
|
|||
|
You should start by redesigning your data model.
Instead of having multiple columns sub1, sub2 etc, you should store the subjects in a separate junction table student (pk,name, ...) subject (pk,name, ...) results (studPk, subPk, score, ...) |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Top 10 scores - Row Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|