Report Builder 3.0 Int问题

时间:2018-05-14 12:51:34

标签: sql sql-server

SSRS新手

我有以下数据集,稍后我将用作参数

我请团队的问题是,我的计数是1,2,3等。

我有以下

选择不同的强制转换(Count as Int)作为Count,                   将(计为Int)作为名称 从表 的 UNION 选择' 0','计数实例'

问题是以粗体显示的行。 0将成为我在所有参数中的默认值,但我得到一个int转换问题。

请帮助

1 个答案:

答案 0 :(得分:1)

UNION位于不同的数据类型之间,UNION之前为INT,之后为VARCHAR

Select distinct cast(Count as Int) as Count --this is INT
    ,Cast(Count as Int) as Name -- this is also INT
from Table 
UNION
select '0' --This is VARCHAR(x)
    , 'Count Number Instance' --this is also VARCHAR(x)

这可能适合你

Select distinct cast(Count as Int) as Count
    ,Cast(Count as VARCHAR(22)) as Name
from Table 
UNION
select CAST('0' AS INT) 
    , 'Count Number Instance'

Count

Table列的数据类型是什么?

在问题中包含您的预期输出,我会相应地更新此答案