我有这个问题:
ALTER procedure [dbo].[shuffleChoices]
@subjectID int, @personID int, @itemCount int
as
SELECT TOP (@itemCount) question,
answer = CONCAT('A. ',CA.[1]),
distractor1 = CONCAT('B. ',CA.[2]),
distractor2 = CONCAT('C. ',CA.[3]),
distractor3 = CONCAT('D. ',CA.[4]),
CONCAT(SUBSTRING(answer,0,2),trueanswer) AS trueanswer
FROM user_items
CROSS APPLY (SELECT *
FROM (SELECT x,
ROW_NUMBER() OVER (ORDER BY CRYPT_GEN_RANDOM(4)) AS rn
FROM (VALUES(answer),
(distractor1),
(distractor2),
(distractor3)) V(x)) ps
PIVOT (MAX(x) FOR rn IN ([1], [2], [3], [4])) p) CA
WHERE subjectID = @subjectID and personID = @personID
ORDER BY NEWID()
这样做可以改变列回答, distractor1 , distractor2 和 distractor3 <的值/ p>
我想做的是得到正确答案的信。列答案和 trueanswer 的值始终相同,但不会在表格内进行混洗。我尝试将回答连接到 trueanswer ,但我得到的结果是:
它总是得到值本身的第一个字符。如何在不更新表格的情况下获取连接的字母?
答案 0 :(得分:0)
我找到了解决方案。我在C#.NET中有一个DataTable。我所做的是比较列回答, distractor1 , distractor2 和列 trueanswer 的值> distractor3 即可。之后,我只是连接了相应的字母,更新了我的DataTable,然后将其绑定到我的reportviewer。对困惑感到抱歉! :)