SELECT
    ntm.Status,
    ntm.No_Ref,
    nj.Description,
    ntm.No_Note,
    ntm.Tgl_Buat,
    ntm.Total,
    ntm.Saldo,
    ntm.Change_Date,
    ntm.Change_By,
    ntm.No_Proposal,
    ntm.Jenis,
    ntm.Tgl_Lunas,
    ntm.Jml_Lunas,
    CASE ntm.Jenis
      WHEN 11 THEN ppd.Tgl_Ubah
      ELSE NULL
    END AS Tgl_Keluar
FROM
    dbo.Note_Jenis AS nj RIGHT OUTER JOIN 
    dbo.Note_Terbit_Master AS ntm ON nj.Kode = ntm.Jenis LEFT JOIN
    (SELECT DISTINCT Tgl_Ubah, No_Ref FROM Peserta_Produk_Detail) AS ppd ON ntm.No_Ref = ppd.No_Ref
WHERE
    ((ntm.Jenis >= 1) AND (ntm.Jenis <= 19) OR (ntm.Jenis IN (34, 33, 31, 90, 100)) OR (ntm.Jenis BETWEEN 60 AND 64))
    AND ntm.No_Proposal = '2014.0423'
    AND ntm.Status = 'G'
ORDER BY
    ntm.No_Ref

