0

SSRS表达条款我有例如查询与回报的东西,因为它凡在max函数

route value 
1  3 
2  2 
3  4 
4  5 
5  1 

然后我需要把2文本框中的最大和最小路线,以便在SQL这将是

select top 1 route from table where value=(select max(value) from table) 

我添加了一个在Excel中完成的图像,这将如何。

enter image description here

我相信这是很容易的,但我没有知道如何得到它。

回答

0

我相信你正在寻找的查询是:

With Min_Max_CTE as (
Select MIN(value) as Min_Value 
    , MAX(value) as Max_Value 

From Table 
) 

Select Top 1 'Min' as Type 
    , T.route 
    , T.value 

From Table T 
    Inner Join Min_Max_CTE CTE 
     on T.value = CTE.Min_Value 

Union All 

Select Top 1 'Max' as Type 
    , T.route 
    , T.value 

From Table T 
    Inner Join Min_Max_CTE CTE 
     on T.value = CTE.Max_Value 

Order by Type desc --This will put the Min Route first followed by the Max Route 

然后,把该查询到的数据集,然后创建一个表矩阵,并使用类型,路线,和值字段返回最小路线和最大路线。它最终应该像上面的最小和最大路径的excel部分一样设置。

0

你可以通过使用几个单独的表来完成SSRS。您的示例数据:在设计

enter image description here

和两个表:

enter image description here

因为只有有标题行的表,只能在表的第一行会显示出来。

为了确保我们得到这两个表中的MAXMIN值,每个表都需要适当地排序它的数据集,即分别按降序和升序排列。

MAX表:

enter image description here

MIN表:

enter image description here

哪个给你预期的结果:

enter image description here

1

我得到了使用表达式,这是您准确表达

="Route "+ 
Convert.ToString (
Lookup(max(fields!value.Value),fields!value.Value ,fields!route.Value,"mydataset") 
) 

变化最大的分钟后,换另一...

感谢大家。