SQL Server 2005 query needed, please help.
I have a table which have questions and all questions are categorized TopicWise wise.
And another table which Contains topic and its weightage of number in the Subject
Now, I need to select 50 random questions from Table QUESTIONS which are based on the weightage of the Topic like out of 50 random selected questions there must be
5 questions from Subtopic_Id=1 and
15 questions from Subtopic_Id=2 and
10 questions from Subtopic_Id=3 and
10 questions from Subtopic_Id=4 and
10 questions from Subtopic_Id=5
See Second image (Table Topics)
and the number of topics and their weightage may vary in different subjects, so union statement will be a bad idea for a dynamic query.
I even have not figure out a single bit of line of code for this selection.
Aucun commentaire:
Enregistrer un commentaire