From: Vincent Le Gallic Date: Sat, 14 Feb 2015 17:17:01 +0000 (+0100) Subject: [depenses.py] Useless inception X-Git-Url: http://gitweb.pimeys.fr/?a=commitdiff_plain;h=c19278d817c4905042175dfcef5ac8965410acad;p=scripts-20-100.git [depenses.py] Useless inception --- diff --git a/bde/stats/depenses.py b/bde/stats/depenses.py index 787a668..1997d4c 100755 --- a/bde/stats/depenses.py +++ b/bde/stats/depenses.py @@ -9,23 +9,21 @@ import psycopg2.extras import sys create_temp_table = """ - SELECT * + SELECT extract(year FROM date) AS annee, + CAST(sum( + CASE WHEN emetteur = %(idbde)s THEN montant * quantite + ELSE 0 + END + )/100.0 AS numeric(10,2)) AS depenses, + CAST(sum( + CASE WHEN destinataire = %(idbde)s THEN montant*quantite + ELSE 0 + END + )/100.0 AS numeric(10,2)) AS gains INTO past - FROM - (SELECT extract(year FROM date) AS annee, - CAST(sum( - CASE WHEN emetteur = %(idbde)s THEN montant * quantite - ELSE 0 - END - )/100.0 AS numeric(10,2)) AS depenses, - CAST(sum( - CASE WHEN destinataire = %(idbde)s THEN montant*quantite - ELSE 0 - END - )/100.0 AS numeric(10,2)) AS gains - FROM transactions - WHERE valide AND %(idbde)s in (emetteur, destinataire) - GROUP BY annee) AS pif + FROM transactions + WHERE valide AND %(idbde)s in (emetteur, destinataire) + GROUP BY annee ; """