• I'm not certain what formatting "####0" represents, it could be padding with spaces or zeros, but basically it would be a CASE expression like so:

    case inc_data.event_type

    when 'c' then 'R'+left('00000'+cast(incident.incident_ref as varchar),5)

    when 'i' then left('00000'+cast(incident.incident_ref as varchar),5)

    else 'P'+left('00000'+cast(incident.incident_ref as varchar),5)

    end

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho