USE [envisage]
GO
/****** Object:  View [dbo].[VW_ScenarioAndProxyDetails]    Script Date: 06/20/2014 21:22:07 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[VW_ScenarioAndProxyDetails]'))
DROP VIEW [dbo].[VW_ScenarioAndProxyDetails]

/****** Object:  View [dbo].[VW_ScenarioAndProxyDetails]    Script Date: 06/20/2014 20:01:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE VIEW [dbo].[VW_ScenarioAndProxyDetails]
AS
SELECT Scenario_Detail.Id, 
    Scenario_Detail.ParentID, 
    Scenario_Detail.ExpenditureCategoryId, 
    Scenario_Detail.WeekEndingDate, 
    Scenario_Detail.Quantity, Scenario_Detail.LastUpdate, 
    Scenario_Detail.WeekOrdinal, Scenario_Detail.Cost, 
    Expenditure.Name AS ExpenditureCategoryName, 
    Expenditure_Category.GLId, 
    Expenditure_Category.UOMId, 
    Expenditure_Category.CreditId, 
    Expenditure_Category.Type, 
    Expenditure_Category.UseType, 
    Expenditure_Category.CGEFX, 
    Expenditure_Category.SystemAttributeOne, 
    Expenditure_Category.SystemAttributeTwo, 
    Expenditure_Category.SortOrder
FROM Scenario_Detail 
	INNER JOIN Expenditure_Category ON Expenditure_Category.Id = Scenario_Detail.ExpenditureCategoryId
    INNER JOIN Expenditure ON Expenditure_Category.ExpenditureId = Expenditure.Id
