[Solved] Concatenate ‘A’ with SQL query


Try following if your implementation is in SQL Server.

SELECT
tblgrade.fld1stGrade +'A'
FROM
tblgrade WHERE CAST(tblgrade.fld1stGrade as int) >= 90 
and cast(tblgrade.fld1stGrade as int) <= 99;

For MySQL implementation use following.

select concat(tblgrade.fld1stGrade, 'A') from tblgrade
where tblgrade.fld1stGrade >= 90 and tblgrade.fld1stGrade <= 99;

For multiple category comparison in MySQL, use something like below.

select 
case
  when tblgrade.fld1stGrade >=90 and tblgrade.fld1stGrade <= 99 
     then concat(tblgrade.fld1stGrade, 'A')
  when tblgrade.fld1stGrade >=80 and tblgrade.fld1stGrade <= 89 
     then concat(tblgrade.fld1stGrade, 'B')
  when tblgrade.fld1stGrade >=70 and tblgrade.fld1stGrade <= 79 
     then concat(tblgrade.fld1stGrade, 'C')
  else concat(details, 'D')
  end
  as Grade
from supportContacts;

3

solved Concatenate ‘A’ with SQL query