0

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Cliff Crerar
  • 433
  • 8
  • 24

1 Answers1

0

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
Cliff Crerar
  • 433
  • 8
  • 24