--------------------------------------------------------------------------------REM
OVING PACKAGES
and pack.package_name not in (
'DemoForGenisis IN Safelink 2',
'IDT Subscriber Package',
'MVNA Aspider Subscriber Package',
'MVNA Aspider Subscriber Package (PayGo)',
'MVNA Aspider Subscriber Package (USF)',
'MVNE Subscriber Package'
)
--gruoping to get max catalouge change id
GROUP BY
CASE
WHEN prod.product_name like '% %' and prod.product_family_id in (5, 6)
THEN 'M2M Services'
WHEN prod.product_name like '% %' and prod.product_family_id not in (5, 6)
THEN 'MVNO Services'
ELSE prod.product_name
END,
CASE
WHEN prod.product_family_id in (5, 6)
THEN 52
ELSE 51
END,
tariff.tariff_name,
pack.package_name) LEGACY
left join
(SELECT
'GENESIS ONLY' SOURCE_SYSTEM,
genesis.product_name,
genesis.product_id,
tariff.tariff_name,
tariff.tariff_desc,
tariff.tariff_id,
genesis.product_family_id,
MAX(tarel.catalogue_change_id) catalogue_change_id,
et.event_type_name event_type_name,
et.event_type_id event_type_ref,
rating.tariff_name wholesale_rate_plan_name,
rating.rating_tariff_id wholesale_rate_plan_ref,
MAX(rating.rating_catalogue_id) rating_catalogue_id
FROM
product genesis,
tariffelement tarel,
tariff tariff,
tariffhasratingtariff thrt,
ratingtariff rating,
ratingtarifftype rtt,
tariffeventbind teb,
eventtype et,
producthaseventtype phet
WHERE
genesis.product_id >= 1500
and genesis.product_id = tarel.product_id (+)
and tarel.tariff_id = tariff.tariff_id (+)
and tarel.catalogue_change_id = tariff.catalogue_change_id (+)
and tariff.tariff_id = thrt.tariff_id (+)
and tariff.catalogue_change_id = thrt.catalogue_change_id (+)
and thrt.rating_tariff_id = rating.rating_tariff_id (+)
--and rating.rating_catalogue_id (+) = 290
and rating.rating_tariff_type_id = rtt.rating_tariff_type_id (+)
and rating.rating_catalogue_id = rtt.rating_catalogue_id (+)
and rtt.rating_tariff_type_id = teb.rating_tariff_type_id (+)
and rtt.rating_catalogue_id = teb.rating_catalogue_id (+)
and teb.event_type_id = et.event_type_id (+)
and et.event_type_id = phet.event_type_id (+)
and tariff.tariff_id = phet.product_id (+)
GROUP BY
genesis.product_name,
genesis.product_id,
tariff.tariff_name,
tariff.tariff_desc,
tariff.tariff_id,
genesis.product_family_id,
et.event_type_name,
et.event_type_id,
rating.tariff_name,
rating.rating_tariff_id) GENESIS
ON
LEGACY.product_name = GENESIS.product_name
AND LEGACY.product_family_id = GENESIS.product_family_id
AND GENESIS.tariff_name = case
when genesis.product_id in (1501, 1509)
then LEGACY.tariff_name
when genesis.product_id = 1510
then '250 Free SMS'
when genesis.product_id = 1511
then '1000 Free SMS'
when genesis.product_id = 1512
then 'Free Unlimited SMS'
when genesis.product_id = 1513
then '400 Free SMS'
when genesis.product_id = 1516
then '100 Free SMS'
when genesis.product_id = 1517
then '30 Free SMS'
when genesis.product_id = 1525
then 'Simple EMPL'
when genesis.product_id = 1526
then 'Simple MULTILINE'
-- TF
when genesis.product_id = 1505
and upper(legacy.package_name) like 'TR%'
then 'Tracfone THRWS31'
when genesis.product_id = 1506
and upper(legacy.package_name) like 'TR%'
then 'Tracfone THRWS32'
when genesis.product_id = 1507
and upper(legacy.package_name) like 'TR%'
then 'Tracfone THRWS33'
when genesis.product_id = 1508
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WADADJTH4'
when genesis.product_id = 1518
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WADADJTH5'
when genesis.product_id = 1519
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WDRADJBLK'
when genesis.product_id = 1520
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WHIADJTHR2'
when genesis.product_id = 1521
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WHIADJTHR1'
when genesis.product_id = 1522
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WHOADJTH2'
when genesis.product_id = 1523
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WIRADJBLK'
-- SMPL
when genesis.product_id = 1505
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple THRWS31'
when genesis.product_id = 1506
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple THRWS32'
when genesis.product_id = 1507
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple THRWS33'
when genesis.product_id = 1508
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WADADJTH4'
when genesis.product_id = 1518
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WADADJTH5'
when genesis.product_id = 1519
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WDRADJBLK'
when genesis.product_id = 1520
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WHIADJTHR2'
when genesis.product_id = 1521
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WHIADJTHR1'
when genesis.product_id = 1522
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WHOADJTH2'
when genesis.product_id = 1523
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WIRADJBLK'
when genesis.product_id in (1527, 1528, 1529, 1530)
then 'M2M '||genesis.product_name
end
AND GENESIS.tariff_desc = case
when genesis.product_id in (1501, 1509)
then LEGACY.package_name
when genesis.product_id = 1510
then '250 Free SMS'
when genesis.product_id = 1511
then '1000 Free SMS'
when genesis.product_id = 1512
then 'Free Unlimited SMS'
when genesis.product_id = 1513
then '400 Free SMS'
when genesis.product_id = 1516
then '100 Free SMS'
when genesis.product_id = 1517
then '30 Free SMS'
when genesis.product_id = 1525
then 'Simple EMPL'
when genesis.product_id = 1526
then 'Simple MULTILINE'
-- TF
when genesis.product_id = 1505
and upper(legacy.package_name) like 'TR%'
then 'Tracfone THRWS31'
when genesis.product_id = 1506
and upper(legacy.package_name) like 'TR%'
then 'Tracfone THRWS32'
when genesis.product_id = 1507
and upper(legacy.package_name) like 'TR%'
then 'Tracfone THRWS33'
when genesis.product_id = 1508
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WADADJTH4'
when genesis.product_id = 1518
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WADADJTH5'
when genesis.product_id = 1519
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WDRADJBLK'
when genesis.product_id = 1520
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WHIADJTHR2'
when genesis.product_id = 1521
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WHIADJTHR1'
when genesis.product_id = 1522
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WHOADJTH2'
when genesis.product_id = 1523
and upper(legacy.package_name) like 'TR%'
then 'Tracfone WIRADJBLK'
-- SMPL
when genesis.product_id = 1505
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple THRWS31'
when genesis.product_id = 1506
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple THRWS32'
when genesis.product_id = 1507
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple THRWS33'
when genesis.product_id = 1508
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WADADJTH4'
when genesis.product_id = 1518
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WADADJTH5'
when genesis.product_id = 1519
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WDRADJBLK'
when genesis.product_id = 1520
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WHIADJTHR2'
when genesis.product_id = 1521
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WHIADJTHR1'
when genesis.product_id = 1522
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WHOADJTH2'
when genesis.product_id = 1523
and upper(legacy.package_name) like 'SIMPLE%'
then 'Simple WIRADJBLK'
when genesis.product_id in (1527, 1528, 1529, 1530)
then 'M2M '||genesis.product_name
end
--ORDER BY PACKAGE_NAME, PRODUCT_NAME DESC
) rbm
on nvl(toms.package_name, 'null') = nvl(rbm.package_name, 'null')
and nvl(toms.product_name, 'null') = nvl(rbm.product_name, 'null')
and nvl(toms.billing_product_name, 'null') = nvl(rbm.billing_product_name,
'null')
and nvl(toms.billing_product_ref, 1) = nvl(rbm.billing_product_ref, 1)
and nvl(toms.wholesale_price_plan_name, 'null') =
nvl(rbm.wholesale_price_plan_name, 'null')
and nvl(toms.wholesale_price_plan_ref, 1) = nvl(rbm.wholesale_price_plan_ref,
1)
and nvl(toms.event_type_name, 'null') = nvl(rbm.event_type_name, 'null')
and nvl(toms.event_type_ref, 1) = nvl(rbm.event_type_ref, 1)
and nvl(toms.wholesale_rate_plan_name, 'null') = nvl(rbm.wholesale_rate_plan_name,
'null')
and nvl(toms.wholesale_rate_plan_ref, 1) = nvl(rbm.wholesale_rate_plan_ref,
1)
where
(toms.package_name is null
or rbm.package_name is null)
--toms.package_name = 'Cintex Subscriber Package1'
--or rbm.package_name = 'Cintex Subscriber Package1'
order by package_name, product_name