USE [GrpInsurance]
GO

/****** Object:  View [dbo].[view_NotePremiPolis_Test]    Script Date: 04/30/2014 17:16:25 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


-- by Pribadi Pamungkas
-- ditambahin kolom Cabang
ALTER VIEW [dbo].[view_NotePremiPolis_Test]
AS
SELECT     TOP 100 PERCENT dbo.Note_Terbit_Master.Status, dbo.Note_Terbit_Master.No_Ref, dbo.Note_Jenis.Description, dbo.Note_Terbit_Master.No_Note, 
                      dbo.Note_Terbit_Master.Tgl_Buat, dbo.Note_Terbit_Master.Total, dbo.Note_Terbit_Master.Saldo, dbo.Note_Terbit_Master.Cabang, dbo.Cabang.Nama AS Nama_Cabang,
                      dbo.Note_Terbit_Master.Change_Date, 
                      dbo.Note_Terbit_Master.Change_By, dbo.Note_Terbit_Master.No_Proposal, dbo.Note_Terbit_Master.Jenis, dbo.Note_Terbit_Master.Tgl_Lunas, 
                      dbo.Note_Terbit_Master.Jml_Lunas
FROM      dbo.Note_Jenis RIGHT OUTER JOIN
          dbo.Note_Terbit_Master ON dbo.Note_Jenis.Kode = dbo.Note_Terbit_Master.Jenis LEFT JOIN
          dbo.Polis_Asuransi ON dbo.Note_Terbit_Master.No_Proposal = dbo.Polis_Asuransi.No_Proposal LEFT JOIN
          dbo.Cabang ON dbo.Note_Terbit_Master.Cabang = dbo.Cabang.Kode AND dbo.Cabang.No_Prs = dbo.Polis_Asuransi.No_Prs
WHERE     (dbo.Note_Terbit_Master.Jenis >= 1) AND (dbo.Note_Terbit_Master.Jenis <= 19) OR
                      (dbo.Note_Terbit_Master.Jenis IN (34, 33, 31, 90, 100)) OR
                      (dbo.Note_Terbit_Master.Jenis BETWEEN 60 AND 64)
ORDER BY dbo.Note_Terbit_Master.No_Ref




GO


