InterBase - 将计算列转换为不同的字符

InterBase - Casting calculated column as varying character

我正在尝试编写一个使用计算值的查询,然后我想将这个计算值转换为一个字符串,以便我可以在末尾添加一个“%”。

但是我没有成功执行以下查询:

select 
    a.Subjects, a.RequiredTime, b.HRS,
    CAST(((b.HRS / a.RequiredTime)*100) as VARCHAR) as PercentageComplete
from 
    Subjects a 
inner join 
    V_SUMMARYHOURSSUBJECT b on a.Subjects = b.Subject

这是查询生成的错误:

Error at line 1 Dynamic SQL Error SQL error code = -104 Token unknown - line 2, char 46 ) SQL

当您想使用 InterBase SQL 将 integer/numeric/double 转换为字符串时;必须将字符串长度指定为 CAST 函数的一部分,例如

select a.Subjects, a.RequiredTime, b.HRS,
CAST(((b.HRS / a.RequiredTime)*100) as VARCHAR(10)) as PercentageComplete
from Subjects a inner join V_SUMMARYHOURSSUBJECT b
on a.Subjects = b.Subject