I have the following data in a SQL table
Temp table variable @RndQuesnCount contains this data,
Recid conceptID MinDisplayCount
1 3839 2
2 4802 3
Question table : QuesTable
QuesCompID Ques_ConceptDtlID
88 4802
89 4802
90 4802
91 4802
92 4802
93 4802
What I would like to show is the min display count for question which is in @RndQuesnCount for the concept id, so now the data should come as below
QuesCompID Ques_ConceptDtlID
88 4802
89 4802
90 4802
because conceptid (4802) has min display count 3 in @RndQuesnCount table.
Can anyone help me to solve this problem ?
Simple use of
ROW_NUMBER()and a join gets the results, I think. Data setup:Query:
Results: