• quote:


    That's why I included a where clause so that if you specif y one studentID you will get 75 rows you could specify several students paging by studentID also.


    Thanks, this has been a big help! The following is what I have set up:

    **************************

    DECLARE @Grade AS Smallint

    DECLARE @TestID AS Varchar(10)

    SET @Grade = 0

    SET @TestID = 'HMKRL3'

    SELECT

    "Grade"=@Grade,

    "TestID"=@TestID,

    Permnum,

    QID,

    CA,

    Case When QNumber = 1 Then Q1

    When QNumber = 2 Then Q2

    When QNumber = 3 Then Q3

    .....

    WHEN QNumber = 75 THEN Q75

    END AS SA,

    'Q'+ str(QNumber,2)AS QuestionNumber

    FROM tblRCScoreImport CROSS JOIN tblRCScoreImportQNumbers

    WHERE permnum = '2000022500'

    ORDER BY Permnum, QuestionNumber

    ***********************************

    In the CASE statement, I call the column 'SA', meaning 'student answer'.

    The variables will be used to help us identify the grade level of the test,

    and the ID of the test.

    'QID' is the 'question ID' and comes from tblRCScoreImportQNumbers,

    'CA' is the 'correct answer' and also comes from tblRCScoreImportQNumbers

    I need two other calculated fields in this query:

    One would compare 'SA' to 'CA' and the result would populate a calculated field called 'Valid' with a 1 if they did match, and a zero if not:

    ***

    IF SA=CA

    @Valid = 1

    ELSE

    @Valid = 0

    ***

    The other would determine whether or not 'SA' was NULL, and if it were not, then would again compare 'SA' to 'CA' and the result would populate a calculated field called 'Result' with a 1 if they did match, and a zero if not:

    ***

    IF SA is NULL

    @Result = 'B'

    ELSE

    IF SA=CA

    @Result = 'C'

    ELSE

    @Result = 'I'

    ***

    The 'IF' statements may seem to be a bit redundant, but I need to go with it for now. How do I work with the value of 'SA' if it is not an actual field (with a variable arrangement of some kind?)Can I handle @Valid and @Result the same way I did 'Grade' and 'TestID'?

    Thanks again for your help!

    CSDunn