---- (6, 11) PESERTA KELUAR ----
SELECT
  *
FROM
  (
    SELECT [Status]
          ,[No_Ref]
          ,[Description]
          ,[No_Note]
          ,[Tgl_Buat]
          ,[Total]
          ,[Saldo]
          ,[Cabang]
          ,[Nama_Cabang]
          ,[Jenis]
          ,[Tgl_Lunas]
          ,[Jml_Lunas]
      FROM [GrpInsurance].[dbo].[view_NotePremiPolis_Test]
    WHERE
      ((Jenis >= 1) 
      AND (Jenis <= 19) 
      OR (Jenis IN (34, 33, 31, 90, 100)) 
      OR (Jenis BETWEEN 60 AND 64))
      
      AND No_Proposal = '2015.0046'
      AND Status='G'
      
      --AND Tgl_Buat>='2014-12-17'
      --AND Tgl_Buat<='2014-12-31'
  ) AS ref
  RIGHT JOIN
  TmpInsurance.dbo.Rep10528_prib_11 AS x ON ref.No_Ref = x.No_Ref
-----------------------------------------------------------------
---- (4, 12) PESERTA PERUBAHAN ----
SELECT
  *
FROM
  (
    SELECT [Status]
          ,[No_Ref]
          ,[Description]
          ,[No_Note]
          ,[Tgl_Buat]
          ,[Total]
          ,[Saldo]
          ,[Cabang]
          ,[Nama_Cabang]
          ,[Jenis]
          ,[Tgl_Lunas]
          ,[Jml_Lunas]
      FROM [GrpInsurance].[dbo].[view_NotePremiPolis_Test]
    WHERE
      ((Jenis >= 1) 
      AND (Jenis <= 19) 
      OR (Jenis IN (34, 33, 31, 90, 100)) 
      OR (Jenis BETWEEN 60 AND 64))
      
      AND No_Proposal = '2015.0046'
      AND Status='G'
      
      --AND Tgl_Buat>='2014-12-17'
      --AND Tgl_Buat<='2014-12-31'
  ) AS ref
  RIGHT JOIN
  TmpInsurance.dbo.Rep10528_prib_12 AS y ON ref.No_Ref = y.No_Ref
-----------------------------------------------------------------
---- (1, 2, 3, 60, 61, 62) PESERTA BARU DAN SUSULAN ----
SELECT
  *
FROM
  (
    SELECT [Status]
          ,[No_Ref]
          ,[Description]
          ,[No_Note]
          ,[Tgl_Buat]
          ,[Total]
          ,[Saldo]
          ,[Cabang]
          ,[Nama_Cabang]
          ,[Jenis]
          ,[Tgl_Lunas]
          ,[Jml_Lunas]
      FROM [GrpInsurance].[dbo].[view_NotePremiPolis_Test]
    WHERE
      ((Jenis >= 1) 
      AND (Jenis <= 19) 
      OR (Jenis IN (34, 33, 31, 90, 100)) 
      OR (Jenis BETWEEN 60 AND 64))
      
      AND No_Proposal = '2015.0046'
      AND Status='G'
      
      --AND Tgl_Buat>='2014-12-17'
      --AND Tgl_Buat<='2014-12-31'
  ) AS ref
  RIGHT JOIN
  TmpInsurance.dbo.Rep10528_prib_3 AS z ON ref.No_Ref = z.No_Ref
