USE $(DATA_BASE_NAME);
GO

DROP VIEW [drtrpt].[DartReviews]
GO

/****** Object:  View [drtrpt].[DartReviews]    Script Date: 2/24/2016 1:58:21 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


CREATE view [drtrpt].[DartReviews]
as
select
                 req.ActivityID as ResearchStudyID
                 , req.ID as REquestID
                 , req.TrackingNumber
                 , rev.ID as ReviewID
                 , rev.Name
                 , rev.CreatedOn as CreatedOn
                 , rev.CreatedBy as CreatedBy
                 , rev.UpdatedOn as ReviewedDate
                 , rev.UpdatedBy as ReviewedBy
                 , Approved as ApprovedDate
                 , Rejected as RejectedDate
                 , ChangeRequested as LastChangeRequestedDate

from hib.Request req
       inner join hib.[Review] rev on req.ID = rev.RequestID
--order by req.ActivityID, req.TrackingNumber, rev.CreatedON


GO
