Files
Customer/CONN/Once/conn#13536.sql
Arthur Egberink ef10e6e8b3 conn#13536
svn path=/Customer/trunk/; revision=13452
2007-11-20 07:31:50 +00:00

94 lines
5.2 KiB
SQL

alter session set nls_territory = 'America'
/* Formatted on 2007/11/19 17:08 (Formatter Plus v4.8.7) */
SELECT actueel.locatie, (select fac_usrdata_omschr from fac_usrdata fud, alg_onrgoedkenmerk ogk
where fac.safe_to_number(ogk.ALG_ONRGOEDKENMERK_WAARDE) = fud.fac_usrdata_key
and ogk.ALG_KENMERK_KEy = 1120
and ogk.ALG_ONRGOED_KEY = actueel.locatie_key
and ogk.ALG_ONRGOED_NIVEAU = 'L') locatietype, actueel.tarieftype, actueel.prijs,
actueel.oppervlakte actueel_opp, contract.oppervlakte contract_opp
FROM (SELECT locatie, locatie_key, tarieftype, prijs, SUM (oppervlakte) oppervlakte,
SUM (oppervlakte) * prijs totaal
FROM (SELECT alg_locatie_omschrijving locatie,
l.alg_locatie_key locatie_key,
alg_srtruimte_code tarieftype,
alg_srtruimte_prijs prijs,
cog.cnt_contract_onrgoed_opp oppervlakte
FROM cnt_contract_onrgoed cog,
alg_ruimte r,
alg_verdieping v,
alg_gebouw g,
alg_locatie l,
alg_srtruimte sr
WHERE cog.alg_onrgoed_niveau = 'R'
AND cog.alg_onrgoed_key = r.alg_ruimte_key
AND r.alg_verdieping_key = v.alg_verdieping_key
AND v.alg_gebouw_key = g.alg_gebouw_key
AND g.alg_locatie_key = l.alg_locatie_key
AND cog.alg_srtonrgoed_key = sr.alg_srtruimte_key
UNION ALL
SELECT alg_locatie_omschrijving locatie,
l.alg_locatie_key locatie_key,
st.alg_srtterreinsector_code tarieftype,
st.alg_srtterreinsector_prijs prijs,
cog.cnt_contract_onrgoed_opp oppervlakte
FROM cnt_contract_onrgoed cog,
alg_terreinsector t,
alg_locatie l,
alg_srtterreinsector st
WHERE cog.alg_onrgoed_niveau = 'T'
AND cog.alg_onrgoed_key = t.alg_terreinsector_key
AND t.alg_locatie_key = l.alg_locatie_key
AND cog.alg_srtonrgoed_key =
st.alg_srtterreinsector_key)
GROUP BY locatie, locatie_key, tarieftype, prijs
ORDER BY 1, 2) contract,
(SELECT locatie, locatie_key, tarieftype, prijs, SUM (oppervlakte) oppervlakte,
SUM (oppervlakte) * prijs totaal
FROM (SELECT alg_locatie_omschrijving locatie,
l.alg_locatie_key locatie_key,
alg_srtruimte_code tarieftype,
alg_srtruimte_prijs prijs,
fac.safe_to_number
(ogk.alg_onrgoedkenmerk_waarde)
oppervlakte
FROM alg_ruimte r,
alg_verdieping v,
alg_gebouw g,
alg_v_aanweziglocatie l,
alg_srtruimte sr,
alg_onrgoedkenmerk ogk
WHERE r.alg_verdieping_key = v.alg_verdieping_key
AND v.alg_gebouw_key = g.alg_gebouw_key
AND g.alg_locatie_key = l.alg_locatie_key
AND r.alg_srtruimte_key = sr.alg_srtruimte_key
AND r.alg_ruimte_key = ogk.alg_onrgoed_key
AND ogk.alg_kenmerk_key = 106
UNION ALL
SELECT alg_locatie_omschrijving locatie,
l.alg_locatie_key locatie_key,
st.alg_srtterreinsector_code tarieftype,
st.alg_srtterreinsector_prijs prijs,
fac.safe_to_number
(ogk.alg_onrgoedkenmerk_waarde)
oppervlakte
FROM alg_terreinsector t,
alg_locatie l,
alg_srtterreinsector st,
alg_onrgoedkenmerk ogk
WHERE t.alg_locatie_key = l.alg_locatie_key
AND t.alg_srtterreinsector_key =
st.alg_srtterreinsector_key
AND t.alg_terreinsector_key = ogk.alg_onrgoed_key
AND ogk.alg_kenmerk_key = 107)
GROUP BY locatie, locatie_key, tarieftype, prijs
ORDER BY 1, 2) actueel
WHERE actueel.locatie = contract.locatie(+) AND actueel.tarieftype = contract.tarieftype(+)
ORDER BY 1, 2
select fac_usrdata_omschr from fac_usrdata fud, alg_onrgoedkenmerk ogk
where fac.safe_to_number(ogk.ALG_ONRGOEDKENMERK_WAARDE) = fud.fac_usrdata_key
-- and ogk.ALG_KENMERK_KEy = 25
and ogk.ALG_ONRGOED_NIVEAU = 'L'