You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.9 KiB
37 lines
1.9 KiB
#Parameter1:Datum von:datetime:now
|
|
#Parameter2:Datum bis:datetime:now
|
|
/* SQL */
|
|
drop table if exists tmp1;
|
|
drop table if exists tmp2;
|
|
drop table if exists tmp3;
|
|
drop table if exists tmp4;
|
|
create Table Tmp2 (
|
|
SELECT
|
|
faktura.Nrfaktura,
|
|
behandlu.Nrbehandlung,
|
|
behandlu.Behandlungsbeginn,
|
|
behandlu.Behandlungsende,
|
|
behandlu.Nrbehandler,
|
|
concat(privat.name, ' ', privat.vorname) AS Behandler,
|
|
behandlu.Nrpatient,
|
|
Concat(privat1.name, ' ', privat1.vorname) AS Patient,
|
|
faktura.total as fakturatotal,
|
|
000000.00 as Leistungen_4000_Total,
|
|
000000.00 as Leistungen_4000_Behandler,
|
|
000000.00 as Leistungen_NE_Rupf,
|
|
000000.00 as Leistungen_Rest
|
|
FROM
|
|
faktura
|
|
INNER JOIN behandlu ON (faktura.Nrbehandlung = behandlu.Nrbehandlung)
|
|
INNER JOIN privat ON (behandlu.Nrbehandler = privat.NRPRIVAT)
|
|
INNER JOIN privat privat1 ON (behandlu.Nrpatient = privat1.NRPRIVAT)
|
|
where datum >= '#Parameter1' and datum < '#Parameter2'and faktura.status<>9
|
|
);
|
|
|
|
update tmp2 set leistungen_4000_Total = (select sum(leistung.total) from leistung where leistung.nrbehandlung=tmp2.nrbehandlung and (leistung.`SSO-Nummer` < 5000) AND (leistung.`SSO-Nummer` > 3999));
|
|
update tmp2 set leistungen_4000_Behandler = (select sum(leistung.total)*0.28 from leistung where leistung.nrbehandler=5305 and leistung.nrbehandlung=tmp2.nrbehandlung and (leistung.`SSO-Nummer` < 5000) AND (leistung.`SSO-Nummer` > 3999));
|
|
update tmp2 set leistungen_ne_rupf = (select sum(leistung.total) from leistung where leistung.nrbehandler<>1 and leistung.nrbehandlung=tmp2.nrbehandlung and (leistung.`SSO-Nummer` < 5000) AND (leistung.`SSO-Nummer` > 3999));
|
|
update tmp2 set leistungen_Rest = (select sum(leistung.total) from leistung where leistung.nrbehandlung=tmp2.nrbehandlung and ((leistung.`SSO-Nummer` < 4000) or (leistung.`SSO-Nummer` > 4999)));
|
|
update tmp2 set behandler = "Terlinden-Dünner" where behandler="Dominique Terlinden-Dünner";
|
|
select * from tmp2 where leistungen_4000_behandler > 0 order by nrfaktura;
|