reporting-services - 将一个数据集返回的多个结果拟合到单个文本框中
问题描述
我有一个数据集,它返回如下结果:
SELECT
[Name]
,[Count]
FROM [dbo].[TestTable1]
ID Name Count
------------------------------------------
1 International school 100
2 World school 200
3 Universe school 400
Here is the international school count: «Expr»
Here is the world school count: «Expr»
Here is the Universe school count: «Expr»
我正在寻找一个结果应该返回如下的表达式:
Here is the international school count: 100
Here is the world school count: 200
Here is the Universe school count: 400
这是我的示例表达式:
=IIF(First(Fields!Name.Value, "CountinOneBox")="International school",(Fields!Count.Value, "CountinOneBox"),"")
注意:sum(Fields!Count.Value, "CountinOneBox") 提供 700
希望我已经正确解释了这一点。我怎样才能得到这个结果?谢谢。
解决方案
我会在 SQL 中执行此操作。我已经在此处复制了您的示例数据,然后将结果字段放入了一个简单的报告中
DECLARE @t table(ID int, [Name] varchar(100), [Count] int)
INSERT INTO @t VALUES
(1, 'International school', 100),
(2, 'World school', 200),
(3, 'Universe school', 400)
DECLARE @s nvarchar(max) = ''
DECLARe @crlf char(2) = char(13) + char(10)
SELECT @s =
@s + 'Here is the '
+ [Name]
+ ' count: '
+ CAST([COUNT] as varchar(10))
+ @crlf
FROM @t
SELECT @s as Result
结果看起来像这样。(我在文本框上设置了一个边框,所以你可以看到它没有换行,它使用了我们添加的 CR/LF。
推荐阅读
- apache-spark - 使用 pyspark 创建外部 Hive 表
- c++ - 不调用自定义分配器方法
- react-native - 当键盘出现时,我的标题标题在 react native expo 中闪烁
- c++ - 如何初始化包含大约 300000 个大小约为 300000 的向量的向量
- neo4j - 如何使用 Java Connector Jar 在 neo4j 中获取所有节点的关系
- android - Twilio Video 界面的 webview 权限错误
- android - 是否有方法或 xml 值来检查布局的剩余空间?
- php - Laravel:根据月份的周数计算整数值
- regex - 多个路径的 nginx 位置正则表达式但无效
- ruby - 使用数组值作为哈希键在 Ruby 中创建嵌套哈希