【发布时间】:2013-10-30 17:00:04
【问题描述】:
假设以下数据集:
declare
@datesTest table(dateId date, someValue int)
insert into
@datesTest
values
('01/01/2013', 15),
('01/01/2013', 15),
('02/01/2013', 0),
('03/01/2013', 27),
('03/01/2013', 27),
('03/01/2013', 27),
('04/01/2013', 44),
('04/01/2013', 44),
('05/01/2013', 0)
/* data is in this format with about 15 other fields that make distinct at this level not viable */
select
*
from
@datesTest;
/* not the average I want */
select
avg(someValue) incorrectAvg
from
@datesTest;
/* the average I do want (avg of distinct) */
select
avg(_1.someValue) correctAvg
from
(
select distinct
*
from
@datesTest
)_1
还假设我无法更改数据集或操作 SQL 中的字段。
从 Reporting Services,我想创建一个自定义函数,以某种形式接受这些值,删除重复项,然后返回真正的平均值。
我遇到的问题是我不确定 SSRS 使用哪种类型的对象将多行传递给自定义函数。
【问题讨论】:
-
什么版本的SSRS?
标签: sql vb.net visual-studio ssrs-2008 aggregate-functions