]> gitweb.pimeys.fr Git - scripts-20-100.git/blob - bde/integrite/memo
f7519c1c9ff550713ae7e910a90c03bb7a037abb
[scripts-20-100.git] / bde / integrite / memo
1 # pour créer la table numcbde,gagne,perdu,effectif :
2
3 SELECT numcbde,(SELECT sum(montant*quantite) FROM transactions WHERE destinataire=main.numcbde AND valide='t') as gagne,(SELECT sum(montant*quantite) FROM transactions WHERE emetteur=main.numcbde AND valide='t') as perdu, (SELECT solde FROM adherents WHERE numcbde=main.numcbde) as effectif FROM adherents as main;
4
5 # et créer la table + en extraire seulement les gens intéressants :
6 # NB : c'est long à exécuter...
7 SELECT numcbde,gagne-perdu,effectif FROM (SELECT numcbde,(SELECT sum(montant*quantite) FROM transactions WHERE destinataire=main.numcbde AND valide='t') as gagne,(SELECT sum(montant*quantite) FROM transactions WHERE emetteur=main.numcbde AND valide='t') as perdu, (SELECT solde FROM adherents WHERE numcbde=main.numcbde) as effectif FROM adherents as main) AS calculs WHERE gagne-perdu!=effectif;