From c3500451e73d6bcd253c1df2b148a94bc774b29f Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Tue, 22 Jan 2019 15:05:14 +0100 Subject: [PATCH] =?utf8?q?Refactoring=20sql-Abfrage=20f=C3=BCr=20Steuertab?= =?utf8?q?elle?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit statt 2 subselects pro Automatik- und Skontokonto, jeweils ein Join, um die Kontonummer und Kontenbeschreibung direkt auszulesen. --- SL/AM.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/SL/AM.pm b/SL/AM.pm index a2ae7d59c..a06f8b309 100644 --- a/SL/AM.pm +++ b/SL/AM.pm @@ -1024,13 +1024,16 @@ sub taxes { t.taxkey, t.taxdescription, round(t.rate * 100, 2) AS rate, - (SELECT accno FROM chart WHERE id = chart_id) AS taxnumber, - (SELECT description FROM chart WHERE id = chart_id) AS account_description, - (SELECT accno FROM chart WHERE id = skonto_sales_chart_id) AS skonto_chart_accno, - (SELECT description FROM chart WHERE id = skonto_sales_chart_id) AS skonto_chart_description, - (SELECT accno FROM chart WHERE id = skonto_purchase_chart_id) AS skonto_chart_purchase_accno, - (SELECT description FROM chart WHERE id = skonto_purchase_chart_id) AS skonto_chart_purchase_description + tc.accno AS taxnumber, + tc.description AS account_description, + ssc.accno AS skonto_chart_accno, + ssc.description AS skonto_chart_description, + spc.accno AS skonto_chart_purchase_accno, + spc.description AS skonto_chart_purchase_description FROM tax t + LEFT JOIN chart tc ON (tc.id = t.chart_id) + LEFT JOIN chart ssc ON (ssc.id = t.skonto_sales_chart_id) + LEFT JOIN chart spc ON (spc.id = t.skonto_purchase_chart_id) ORDER BY taxkey, rate|; my $sth = $dbh->prepare($query); -- 2.20.1