USE [GrpInsurance]
GO

--SET ANSI_NULLS ON
--GO

--SET QUOTED_IDENTIFIER ON
--GO


--ALTER VIEW [dbo].[custPort_View_Info_Produk_Kelas]
--AS

--SELECT DISTINCT
--  x.no_Proposal,
--  x.no_Polis,
--  x.kode_Produk,
--  x.Kelas
--FROM
--  (
--    SELECT TOP (100) PERCENT
--      pa.No_Proposal AS no_Proposal,
--      pa.No_Polis AS no_Polis,
--      pp.Id_Produk AS kode_Produk,
--      pp2.kelas
--      --kbp.Kelas
--    FROM
--      dbo.Polis_Asuransi AS pa INNER JOIN
--      dbo.Produk_Polis AS pp ON pa.No_Proposal = pp.No_Proposal INNER JOIN
--      dbo.Premi_Polis AS pp2 ON pp.Id_Produk = pp2.Id_Produk
--      --dbo.Kelas_Benefit_Polis AS kbp ON pp.Id_Produk = kbp.Id_Produk
--    WHERE
--      pp.Status = 'I'
--    ORDER BY
--      pp.Id_Produk,
--      pp2.Urut
--      --pp2.Kelas
--      --kbp.Kelas
--  ) AS x
  

--GO
-----------------------------------

SELECT
	*
FROM
	custPort_View_Info_Produk_Kelas
WHERE
  no_Proposal = '2014.0683'

SELECT
  pa.No_Proposal,
  pa.No_Polis,
  pp.Id_Produk,
  kbp.Kelas
FROM
  dbo.Polis_Asuransi AS pa INNER JOIN
  dbo.Produk_Polis AS pp ON pa.No_Proposal = pp.No_Proposal INNER JOIN
  dbo.Kelas_Benefit_Polis AS kbp ON pp.Id_Produk = kbp.Id_Produk
WHERE
  pa.No_Proposal = '2014.0683'

SELECT *
FROM Kelas_Benefit_Polis