细胞不排成每排

时间:2016-04-08 15:33:16

标签: reporting-services ssrs-2008 ssrs-2008-r2 ssrs-2012 reportbuilder3.0

我有一个我在Report Builder 3.0中构建的SSRS矩阵报告。数据看起来不错,但行不排成一行。每个单元格都在一个单独的行中,使报告难以跟踪和阅读。

以下是截图:

Sample Report

以下是报告所依据的示例数据:

SELECT 's111' AS sessionID, 'q1' AS questionID, 'q1_a1' AS answerID,
'True/False : The Sun orbits the Earth.' AS stem,
'True' AS SelectedItem, 'False' AS UnselectedItem
UNION ALL
SELECT 's111', 'q2', 'q2_a1',
'MCQ: What planet is the largest gas giant in our solar system?',
'Jupiter', 'Moon'
UNION ALL
SELECT 's111', 'q2', 'q2_a2',
'MCQ: What planet is the largest gas giant in our solar system?',
'Jupiter', 'Venus'
UNION ALL
SELECT 's111', 'q2', 'q2_a3',
'MCQ: What planet is the largest gas giant in our solar system?',
'Jupiter', 'Vulcan'
UNION ALL
SELECT 's111', 'q2', 'q2_a4',
'MCQ: What planet is the largest gas giant in our solar system?',
'Jupiter', 'Pluto'
UNION ALL
SELECT 's111', 'q3', 'q3_a1',
'MCQ/Many: Pick the items that best describe why Mars does NOT currently support complex life.',
'God hates Martians', 'Intense radiation from the Sun'
UNION ALL
SELECT 's111', 'q3', 'q3_a2',
'MCQ/Many: Pick the items that best describe why Mars does NOT currently support complex life.',
'God hates Martians', 'Very dry, little to no liquid water'
UNION ALL
SELECT 's111', 'q3', 'q3_a3',
'MCQ/Many: Pick the items that best describe why Mars does NOT currently support complex life.',
'God hates Martians', 'very cold'
UNION ALL
SELECT 's111', 'q3', 'q3_a4',
'MCQ/Many: Pick the items that best describe why Mars does NOT currently support complex life.',
'God hates Martians', 'Intense radiation from an ancient nuclear holocaust'

有没有办法修复行?

谢谢!

1 个答案:

答案 0 :(得分:2)

好的,所以我猜这是某种测试,你在查询可用的答案?如果是这样,那么您的问题在于查询中的联接。问题是,每次返回给定问题的答案时,查询都会查找其他问题的空值。我的猜测是你的SQL看起来像这样:

Select s.student_name
    , q.question_txt
    , a.answer_txt

From student_table s
    left outer join question_table q
        on --something
    left outer join answer_table a
        on q.question_id = a.question_id

当您使用答案ID交叉引用问题ID时,您将在每行中返回空值,除非问题ID与针对该问题返回的答案匹配。

有两种基本解决方案,一种简单,一种更复杂。如果你碰巧在问题中有一个自动递增的数字(即答案1的值总是1,答案2的值总是2),那么你可以简单地将这个数字添加到你的查询中并且子组名称和自动递增数字的行组。

如果您的数据中没有这样的数字,您可以通过在数据集中添加以下字段来人工创建一个数字,并为您的Tablix添加一个组:

row_number() over (partition by question_id order by question_id, answer_id) as row

如果我在假设中完全偏离此处,请通过评论告诉我,我会尽力帮助。