I am attempting to write a query that uses a calculated value, I then want to cast this calculated value as a string so that I can add a '%' to the end.
However I am not succeeding with the query below:
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
This is the error that the query generates:
Error at line 1 Dynamic SQL Error SQL error code = -104 Token unknown - line 2, char 46 ) SQL
When you want to convert from integer/numeric/double to a string using InterBase SQL; a string length must be specified as part of the CAST
function for example
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.