--SELECT
--  pp.*
--FROM
--  dbo.temp_prib_peserta_map_20160225 AS sumber INNER JOIN
--  dbo.Peserta AS pst ON sumber.no_proposal = pst.No_Proposal
--                        AND sumber.no_peserta = pst.No_Peserta INNER JOIN
--  dbo.Peserta_Produk AS pp ON pst.No_Proposal = pp.No_Proposal
--                        AND pst.No_Peserta = pp.No_Peserta
--WHERE
--  sumber.grade <> pst.Grade

----- merahin produk
------ cek dulu
----SELECT
----	*
----FROM
----	dbo.Peserta_Produk
----WHERE
----  No_Proposal = '2015.0680'
----  AND No_Peserta = '2014029039-0'
----SELECT pp.*
--UPDATE
--  pp
--SET
--  Status = 'G'
--FROM
--  dbo.temp_prib_peserta_map_20160225 AS sumber INNER JOIN
--  dbo.Peserta AS pst ON sumber.no_proposal = pst.No_Proposal
--                        AND sumber.no_peserta = pst.No_Peserta INNER JOIN
--  dbo.Peserta_Produk AS pp ON pst.No_Proposal = pp.No_Proposal
--                        AND pst.No_Peserta = pp.No_Peserta
--WHERE
--  sumber.no_proposal = pp.No_Proposal
--  AND sumber.no_peserta = pp.No_Peserta


-- merahin peserta
--SELECT
--	*
--FROM
--	dbo.Peserta
--WHERE
--  No_Proposal = '2015.0680'
--  AND No_Peserta = '2014029039-0'
--SELECT
--  pst.*
--UPDATE
--  pst
--SET
--  Status = 'I',
--  Tgl_Lapse = NULL,
--  Grade = sumber.Grade,
--  NIK = sumber.NIK
--FROM
--  dbo.temp_prib_peserta_map_20160225 AS sumber INNER JOIN
--  dbo.Peserta AS pst ON sumber.no_proposal = pst.No_Proposal
--                        AND sumber.no_peserta = pst.No_Peserta
--WHERE
--  sumber.no_proposal = pst.No_Proposal
--  AND sumber.no_peserta = pst.No_Peserta


SELECT
  *
FROM
  dbo.temp_prib_peserta_map_20160225 AS sumber LEFT JOIN
  dbo.Peserta AS pst ON sumber.No_Proposal = pst.No_Proposal
                        AND sumber.No_Peserta = pst.No_Peserta
WHERE
  sumber.no_proposal = pst.No_Proposal
  AND sumber.no_peserta = pst.No_Peserta
  AND sumber.Sex<>pst.Kelamin
