Would this do what you want?
SELECT ficmolde, ficmater, ;
SUM(IIF( movimento <= 50, Quantidade, 0)) - ;
SUM(IIF( movimento >= 51, Quantidade, 0)) AS Balance, ;
from ficmvmp ;
group by 1,2 ;
ORDER BY 1,2
>Hi Sergey,
>
>Thank's, Edgar tell me that a few moments ago.
>
>But the query doesn't do what i expected, this query group in one record all the in and out records, what i need is the group customer then by Ref(Product) all in and out records, any chance. If you can see my first question.
>
>Because any customer could have one or more ref(Product) in my stock.
>
>>>>>you query doesn't take in account movimento values of 50 and 51. Is it intentional?
>
>No only test purpose...:)
>
>Thank's for your time..
>
>João
--sb--