

SELECT
  p.No_Peserta,
  SUM(pp.Premi),
	SUM(pp.Curr_Premi),
	-- yg betul
	SUM(pp.Premi * 1.0 * DATEDIFF(DAY, pp.Tgl_Mulai, p.Tgl_Selesai + 1)/DATEDIFF(DAY, pa.Tgl_Mulai, pa.Tgl_Selesai + 1))
FROM
	dbo.Polis_Asuransi AS pa INNER JOIN
	dbo.Peserta AS p ON pa.No_Proposal = p.No_Proposal INNER JOIN
	dbo.Peserta_Produk AS pp ON p.No_Proposal = pp.No_Proposal AND p.No_Peserta = pp.No_Peserta
WHERE
  pa.No_Proposal = '2014.0835'
  AND pp.Id_Produk = '2014.03385' -- Rawat Jalan GT 2014 (B)
  AND p.No_Peserta = '1991008535-0'
GROUP BY
  p.No_Peserta



SELECT
	pa.Periode_Bayar,
	pb.Deskripsi,
	pa.No_Proposal
FROM
	dbo.Polis_Asuransi AS pa INNER JOIN
	dbo.Perusahaan AS p ON pa.No_Prs = p.No_Prs INNER JOIN
	dbo.Periode_Bayar AS pb ON pa.Periode_Bayar = pb.Kode
WHERE
  p.GT_OG = 'GT'
  AND pa.Status = 'I'
  pa.No_Proposal = '2014.0835'
  
SELECT
	*
FROM
	dbo.Periode_Bayar AS pb
	