I hope someone can help,
tblMatrix
QuestionTypeID QuestionGradeID Quantity
3546 1261 2
3548 1262 3
3548 1263 1
tblQuestions
QuestionID QuestionTypeID QuestionGrade
4523 3546 1261
4524 3546 1261
4525 3546 1261
4527 3546 1261
4555 3546 1262
4528 3548 1262
4529 3548 1262
4530 3548 1262
4531 3548 1262
4532 3548 1262
4533 3548 1263
4533 3548 1263
4533 3548 1263
I have two tables namely tblQuestions & tblMatrix (see above).
The tblQuestions table stores numerous questions of different types and grades.
The tblMatrix table stores records referring to combinations of QuestionTypes & Grades, along with a quantity value.
What I am trying to do is select a number of random records from the tblQuestions table, the total number of records being equal to the quantity value in the tblMatrix table
i.e. Looking at table tblMatrix,
1.for QuestionTypeID = 3546 & QUestionGradeID = 1261 I'd like to retrieve 2 random records from the possible 4 records in tblQuestions that have the same question & grade values.
2.for QuestionTypeID = 3548 & QUestionGradeID = 1262 I'd like to retrieve 3 random records from the possible 5 records in tblQuestions that have the same question & grade values.
I've succeeded in doing this using a cursor, however i wondered if there was a better way using a select statement.
Regards
tblMatrix
QuestionTypeID QuestionGradeID Quantity
3546 1261 2
3548 1262 3
3548 1263 1
tblQuestions
QuestionID QuestionTypeID QuestionGrade
4523 3546 1261
4524 3546 1261
4525 3546 1261
4527 3546 1261
4555 3546 1262
4528 3548 1262
4529 3548 1262
4530 3548 1262
4531 3548 1262
4532 3548 1262
4533 3548 1263
4533 3548 1263
4533 3548 1263
I have two tables namely tblQuestions & tblMatrix (see above).
The tblQuestions table stores numerous questions of different types and grades.
The tblMatrix table stores records referring to combinations of QuestionTypes & Grades, along with a quantity value.
What I am trying to do is select a number of random records from the tblQuestions table, the total number of records being equal to the quantity value in the tblMatrix table
i.e. Looking at table tblMatrix,
1.for QuestionTypeID = 3546 & QUestionGradeID = 1261 I'd like to retrieve 2 random records from the possible 4 records in tblQuestions that have the same question & grade values.
2.for QuestionTypeID = 3548 & QUestionGradeID = 1262 I'd like to retrieve 3 random records from the possible 5 records in tblQuestions that have the same question & grade values.
I've succeeded in doing this using a cursor, however i wondered if there was a better way using a select statement.
Regards