jeudi 29 octobre 2015

Translate SQL column result into text

I have some SQL that selects columns from tables like normal. However, one of my columns (u.cmc_rti_type) is a number and I want it to output text instead. I assume I need some sort of if statement. Here is my sql:

    SELECT '', s.student_number, s.lastfirst, s.grade_level, t.TEACHER, u.cmc_rti_tier, u.cmc_rti_type
            FROM students s 
            JOIN u_def_ext_students u
            ON u.studentsdcid = s.dcid
            LEFT JOIN cmc_homeroom_teacher t
            ON s.dcid = t.dcid
            WHERE u.cmc_rti_tier <> 0
            ORDER BY s.lastfirst

if u.cmc_rti_type is 1 then I want it to output 'Reading'
if u.cmc_rti_type is 2 then I want it to output 'Math'
if u.cmc_rti_type is 3 then I want it to output 'Enrichment'
if u.cmc_rti_type is 4 then I want it to output 'Both Math & Reading'

Aucun commentaire:

Enregistrer un commentaire