From e162424c8187437873ce0b8baadfbaca7b9ff635 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Wed, 20 Jan 2021 16:14:07 +0100 Subject: [PATCH] monatl. forderung --- monatliche-forderungen.sql | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 monatliche-forderungen.sql diff --git a/monatliche-forderungen.sql b/monatliche-forderungen.sql new file mode 100644 index 0000000..5c17526 --- /dev/null +++ b/monatliche-forderungen.sql @@ -0,0 +1,26 @@ +create or replace view monatl_forderung_heute as + select + m.id as mieter, + w.id as wohnung, + o.id as objekt, + w.flaeche as flaeche, + b.betrag as bkv_qm, + (b.betrag * w.flaeche) as bkv, + mz.betrag as miete_qm, + (mz.betrag * w.flaeche) as miete + from + mieter m, + objekt o, + wohnung w, + betriebskosten_vorauszahlung b, + miete mz + where + o.id = w.objekt and + w.id = m.wohnung and + o.id = b.objekt and + w.id = mz.wohnung and + b.gueltig_ab <= now() and + (b.gueltig_bis is null or b.gueltig_bis >= now()) and + mz.gueltig_ab <= now() and + (mz.gueltig_bis is null or mz.gueltig_bis >= now()); +