【问题标题】:RDL merge/split rows based on conditionsRDL 根据条件合并/拆分行
【发布时间】:2020-03-23 17:50:36
【问题描述】:

我有一个像

这样的数据集
Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10
1       a       d       1       1       0+1     2       1       2       1
1       b       e       1       1       1+3     8       4       2       1
1       b       e       2       1       1+3     8       4       2       1
1       b       e       3       1       1+3     8       4       2       1
1       b       e       5       1       1+3     8       4       2       1
1       c       f       1       1       0+1     2       1       2       1

我希望我的报告显示为

Column1 Column2 Column3 Column4 Column5 Column6 Column7 Column8 Column9 Column10
1       a       d       1       1       0+1     2.00    1       2.00    1
1                       1                       2.00    
1       b       e       2       1       1+3     8.00    4       2.00    1
1                       3                       2.00    
1                       5                       2.00    
1       c       f       1       1       0+1     2.00    1       2.00    1

基本上我需要将具有相同数据的行合并在一起(仅限某些列)。是否有可能在 rdl 中实现这一点?我遇到一个论坛说这在 rdl 中是不可能实现的。我也尝试过使用子报表,但无法实现我想要的布局。或者我可能需要以某种方式更改数据集?

【问题讨论】:

  • 您似乎没有合并它们,只是在后续行中隐藏值,我认为是基于 Column4?
  • 如果您想在 SQL 中解决它,请按原样发布您的 SQL。
  • 嗨@DaleK,感谢您的回复,我需要我的 rdl 报告来显示具有相同数据的行在这些列中出现合并,而不是完全隐藏它们,更多地考虑 Excel 方式。我真的不想在 SQL 中解决它,而是在 rdl 中解决它。但是我用 SQL 准备了我的数据集,我担心它的当前形式可能不适合我在 rdl 中呈现我想要的布局。很抱歉造成任何混乱。

标签: sql sql-server rdlc rdl


【解决方案1】:

这应该有效;

;with T as
(select ROW_NUMBER() OVER (PARTITION BY     Column1,column2,column3,column5,column6,column7,column8,column9,column10 ORDER BY Column4) rn
,Column1
,column2
,column3
,column4
,column5
,column6
,column7
,column8
,column9
,column10
from <your_table_name>
)
select 
Column1
,case rn     when 1 then column2      else '' end as column2
,case rn     when 1 then column3      else '' end as column3
,column4
,case rn     when 1 then column5      else '' end as column5
,case rn     when 1 then column6      else '' end as column6
,case rn     when 1 then column7      else '' end as column7
,case rn     when 1 then column8      else '' end as column8
,case rn     when 1 then column9      else '' end as column9
,case rn     when 1 then column10     else '' end as column10
from T

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-15
    • 1970-01-01
    • 2017-06-17
    相关资源
    最近更新 更多