>select 1 as dummy, * from tmpbal into cursor tmp ;
>union all select -1 as dummy, * from pc ;
>union all select 1 as dummy, * from pay
>
>select client_num,client_src,SUM(dummy*amount) as balance ;
>from tmp ;
>group by 1,2
Ok, I got it. Finally! It turned out that my tmpbal cursor was wrong to begin with, so maybe my way might have worked? Your way is better, though, so it worked out good.
I had to rearrange your SQL (It didn't like the -1 after having a 1 for the first one) and add some dates (Duh, it helps to get trips and payments from the right billing period, eh? :) But, finally, it is giving me previous balances of all 0.
Now I need to test it when they _do_ have previous balances. :)
Thanks a lot for your help. You're a life saver.
-Michelle
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement