Add views of COSTS table, include effectivity details.

git-svn-id: http://locode01.ad.dom/svn/WEBMIP/trunk@3017 248e525c-4dfb-0310-94bc-949c084e9493
This commit is contained in:
hardya
2007-12-18 17:13:38 +00:00
parent c71e701c68
commit 2e88e639ca
6 changed files with 131 additions and 1 deletions

25
Schema/V_BACO.vw Normal file
View File

@@ -0,0 +1,25 @@
CREATE OR REPLACE VIEW V_BACO AS
SELECT bas_code
,description
,selling_price
,cost_price
,delivery_cost
,regi_code
,valid_from AS effective_from
,least(nvl(valid_to
,to_date('2099'
,'yyyy'))
,nvl(next_valid_from
,to_date('2099'
,'yyyy'))) AS effective_to
FROM (SELECT bas_code
,description
,selling_price
,cost_price
,delivery_cost
,regi_code
,valid_from
,valid_to
,lead(valid_from) over(PARTITION BY cost.bas_code, regi_code ORDER BY valid_from) AS next_valid_from
FROM costs cost
WHERE cost_type = 'BACO');