Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
1.11/5 (2 votes)
See more:
I have two tables:

1.ChapterQuest columns(Id(int),QuestionId(int),Question(varchar(max),OptionA(varchar(100)),
OptionB(varchar(100)),OptionC(varchar(100)),Answer(varchar(10),Ismultiple(bit))

2.ChapterQuestAnswer columns(Id(int),ChapterQuestionID(int),OptionSelect(varchar(10))

Data In ChapterQuest is:

Id  QuestionId  Question  OptionA  OptionB  OptionC  Answer  Ismultiple
1     1         Test       T1       T2        T3       A,B     True

2     2         Test1      TT1      TT2       TT3       A,C       True

3     3         Test2      TTT1      TTT2       TTT3       A       FALSE

Data in ChapterQuestAnswer is:

Id  ChapterQuestionId  OptionSelect
1         1                A,B

2         2                C,A

3         3                 B

How i get Attempted,Wrong Answer,UnAttempted


Plz give some logic for solve my problem ..
Thanks in advance
Posted
Updated 8-Sep-13 20:43pm
v3
Comments
jaideepsinh 9-Sep-13 3:10am    
Can you elaborate your question?

1 solution

Hi ,

This will give you your desired result if values inserted in your answer field and optionselect without any space in between the answer and sperated by comma.

For Right answer

select * from ChapterQuestAnswer t join ChapterQuest q on t.questionid= q.chapterquestionid and t.answer=q.optionselect

For Wrong Answer
select * from ChapterQuestAnswer t join ChapterQuest q on t.questionid= q.chapterquestionid and t.answer <> q.optionselect

or you can view questionid( not attempted) not there in your chapteranswer like this

select * form ChapterQuest where QuestionId not in ( select distinct ChapterQuestionId from ChapterQuestAnswer )

Regards,
Mubin
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900