Hi there I'm working on a sort of survey where there is a table with categories and a table with questions in the categories, so when you combine them you get something like
Catname Catorder Question Questionorder
Cat1 1 Q1 1
Cat1 1 Q2 2
Cat2 2 Q3 1
Cat2 2 Q4 2
etc.
So, whenever someone is answering for example Q3, I would like to click a button and go to the next unanswered question.
This is what I have so far, however, it is not ideal, because if you are at Q3 and Q1 is not answererd yet, it will go to Q1. However, it should go to Q4
So instead of going to the next unaswered question, it will show the first unanswered question:
SELECT
dt.QuestionID,
cat.CategoryID
FROM
UserSurveys ct
INNER JOIN
Dossier_Details dt
ON
ct.Dossierguid = dt.Dossierguid
Inner join
tbl_Questions vr
ON
vr.QuestionId = dt.QuestionId
inner join
SurveyQuestions ti
on
vr.CategoryId = ti.CategoryId
WHERE
(ct.UserID=@UserID)
And
(dt.Status='Unanswered')
Order by
ti.Order asc, vr.Order asc