Repository navigation
Expand file tree
/
Copy pathRetail structure before explosion.sql
More file actions
33 lines (32 loc) · 2.19 KB
/
Copy pathRetail structure before explosion.sql
File metadata and controls
33 lines (32 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
select tbc.retail_tariff
,tbc.retail_component,t.code as timeband
,t.date_from,t.date_to,t.time_from,t.time_to,t.weekday,
s.class, s.DefaultNetworkTariff,s.Patch,s.KVA,s.ret_tariff_comp_description,s.RetailTariffType,
s.retail_component_l1,s.retail_component_l2,s.retail_component_l3
from pricing.pricing_timebands t
inner join
(SELECT retail_tariff_class_patch_id_Code as retail_tariff
,tariff_component_Code as retail_component,u.tbs as timeband
FROM AGL_MDS.pricing.pricing_retail_tariff_component_timeband
unpivot (tbs for tb in (tb1_Code,tb2_Code,tb3_Code,tb4_Code,tb5_Code,tb6_Code,tb7_Code,tb8_Code,tb9_Code,tb10_Code)) u
where state='Active' and VersionFlag='Active') tbc
on tbc.timeband=t.code and t.VersionFlag = 'Active' and t.State = 'Active'
inner join (
select c.Name as ret_tariff_comp_description, c.code as ret_tariff_component,
c.retail_component_l1,c.retail_component_l2,c.retail_component_l3,cm.class,
cm.Retail_Tariff_Code,cm.Patch,cm.KVA,cm.RetailTariffStructure,cm.DefaultNetworkTariff,cm.RetailTariffType
from pricing.pricing_retail_tariff_components c
inner join (
select Code as Retail_Tariff_Code,
patch_id_Code as Patch,
retail_tariff_id as RetailTariffStructure,
Class_code as class,
retail_tariff_type_Code as RetailTariffType,
default_network_tariff_Code as DefaultNetworkTariff,
[KVA demand_Code] as KVA,
u.comps as retail_component
from AGL_MDS.pricing.pricing_retail_tariff
unpivot(comps for comp in (c1_Code,c2_Code,c3_Code,c4_Code,c5_Code,c6_Code,c7_Code,c8_Code,c9_Code,c10_Code)) u
where State = 'Active' and VersionFlag = 'Active') cm
on cm.retail_component=c.Code) s
on s.Retail_Tariff_Code=tbc.retail_tariff and s.ret_tariff_component=tbc.retail_component