TECH_NET
asked on
SQL QUery issue
I am not sure how i could perform a sub query within a query.
Typically, i am trying to compute the Score for all correct answer and score for all wrong answer and finally calculate the total score.
I put up a SQL but need some guidance. Thanks in advance.
Typically, i am trying to compute the Score for all correct answer and score for all wrong answer and finally calculate the total score.
I put up a SQL but need some guidance. Thanks in advance.
CREATE PROCEDURE [dbo].[ExamMode_PostTestScores]
(
@EXAM_REFERENCE_CODE nvarchar(50),
@USER_ID int,
@REQUESTOR_ID int
)
AS
BEGIN
INSERT INTO TEST_SCORE_CARD
(
EXAM_REF_CODE,
USER_ID,
REQUESTOR_ID,
SCORE_YES,
SCORE_NO,
SCORE_FINAL,
CREATE_DATE
)
SELECT
@EXAM_REFERENCE_CODE,
@USER_ID,
@REQUESTOR_ID,
SELECT SUM(MARK_ALLOCATED) FROM CESV WHERE CORRECT_ANSWER_ID=QUESTION_RESPONSE_ID AND EXAM_REFERENCE_CODE=@EXAM_REFERENCE_CODE AS SCORE_YES ,
SELECT SUM(MARK_ALLOCATED) FROM CESV WHERE CORRECT_ANSWER_ID <>QUESTION_RESPONSE_ID AND EXAM_REFERENCE_CODE=@EXAM_REFERENCE_CODE AS SCORE_NO,
SUM(SCORE_YES, SCORE_NO) AS SCORE_TOTAL
getdate()
FROM
EXAMINATION_SCHEDULER_VIEW CESV
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I get the following error
Incorrect syntax near ')'.
Incorrect syntax near ')'.
ASKER
The final query was missing a END. (BEGIN END BLOCK). Thanks for everything.
The explaination was simple and easy to follow.
The explaination was simple and easy to follow.
Great! Sorry about that END block... trying to go from memory here! :-)
Open in new window