Let's start with the easy part:
SELECT
[QuizResultId],
[EmployeeId],
[QuizDate],
[QuizId],
( ) as AnsweredCorrect
FROM
[dbo].[QuizResult] qr
WHERE
[QuizResultId] = QuizResultId
just a normal select, pulling 4 columns and something else
from QuizResult
for the QuizResult you care about ( QuizResultId).
That "something else" bit is a correlated sub
query, it's going out to grab
the count of correct answers for a particular quiz result,
that particular
quiz result happens to match qr.quizresultid that in your
main query you
specified was quizresultid.
you could look at this query individually, just substitute
quizresultid (or
the literal value) for qr.quizresultid. basically it's
going to find all
the answers associated with that quizresultid, that were
correct (=1) and
summing them up (count *).
( select count(*) from quizresultanswer qra, quizanswer qa
where qra.quizanswerid = qa.quizanswerid
and correct = 1
and qra.quizresultid = qr.quizresultid ) as
AnsweredCorrect
That help at all?
--
Jeff Schoolcraft
http://thequeue.net/blog/
a>
http://blogginga
bout.net/blogs/jeff/
Quid quid latine dictum sit, altum videtur
[Non-text portions of this message have been removed]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:AspNetAnyQuestionIsOk-digest@yahoogroups.com
mailto:AspNetAnyQuestionIsOk-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|