【问题标题】:cells not lining up in each row未在每一行中排列的单元格
【发布时间】:2016-04-08 15:33:15
【问题描述】:

我有一个在 Report Builder 3.0 中构建的 SSRS 矩阵报表。数据看起来不错,但行不对齐。每个单元格都位于单独的行中,使报告难以理解和阅读。

这是截图:

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

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'

有没有办法修复这些行?

谢谢!

【问题讨论】:

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


    【解决方案1】:

    好的,我猜这是您查询可用答案的某种测试?如果是这样,那么您的问题在于查询中的联接。问题是查询每次返回给定问题的答案时都会为其他问题找到空值。我的猜测是您的 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
    

    如果我的假设完全偏离了这里,请通过评论告诉我,我会尽力提供帮助。

    【讨论】:

    • 我添加了对样本数据的查询
    • 感谢您提供示例数据,但我的建议是问题在于您加入的方式以及检索数据的方式。因此,样本数据没有什么帮助,因为我们已经可以在您的图像中看到数据。
    猜你喜欢
    • 2019-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-09
    • 1970-01-01
    • 2021-08-13
    • 2015-11-19
    • 2012-11-09
    相关资源
    最近更新 更多