Concatenate SQL Case Expression

So I'm trying to combine values in each new column that I created in view with a case statement. How would I go about doing this?

SELECT
    PI.Patient_UID, PI.FirstName, PI.LastName, 
    AP.ApptStatus, AP.VisitPosted, CD.TotalDue,
    AP.Appointment_UID,
    CASE 
        WHEN AP.VisitPosted = 0 
            THEN 'Visit Posted Error' 
    END Error1,
    CASE 
        WHEN (CD.TotalDue IS NULL OR CD.TotalDue = '')  
            THEN 'Gross Charge Error' 
    END Error2
FROM
    vw_ODBC_pt_PatientInfo AS PI
INNER JOIN
    vw_ODBC_appts_Appointments AS AP ON AP.PatientFID = PI.Patient_UID
INNER JOIN
    vw_ODBC_actv_ChargeDetail AS CD ON CD.PatientFID = PI.Patient_UID 
WHERE
    AP.ApptStatus NOT IN ('10', '11', '12');

I need the new columns Error1 and Error2 to be concatenated as such:

Error1                Error2               ErrorsCombined
Visit Posted Error    Gross Charge Error    Visit Posted Error;Gross Charge Error
Visit Posted Error    NULL                  Visit Posted Error;
Visit Posted Error    NULL                  Visit Posted Error;
Visit Posted Error    NULL                  Visit Posted Error;

Any help would be greatly appreciated! Thanks in advance.



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation