Toad World® Forums

Teradata, SQL, converting numeric to Char & add %


#1

Hi, trying to convert a numeric value to char and add % sign.

Getting error that I am missing something "like ‘(’ between the ‘VarChar’ keyword and ‘,’

Any thoughts please?

Thank you

WHP

SELECT “Med or Surg” AS “Med or Surg”
, COUNT() AS “Total Admits”
, SUM(“30DyReAdFLG”) AS “Flagged ReAdmits”
, COUNT(
) - SUM(“30DyReAdFLG”) AS “Non Flagged Readmits”
, CONVERT(VARCHAR, SUM(“30DyReAdFLG”)* 100 / COUNT(*)) + ‘%’ AS Percentage

FROM ar_asrh_dm_etl_beacon.Flg_ReAdAlgo1a2
WHERE AdmitProvRend_id2 = 139874
GROUP BY “Med or Surg” ORDER BY “Total Admits” DESC;


#2

Try to use this one

cast(SUM(“30DyReAdFLG”)* 100 / COUNT(*) as varchar(10)) || ‘%’ AS Percentage

Aleksey


#3

Thank you Sir. Very helpful!

WHP