]> gitweb.pimeys.fr Git - scripts-20-100.git/blob - bde/old/integrite/memo
[bde] Rangement
[scripts-20-100.git] / bde / old / 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;