Perform calculation in SQL command

1

I made a select command on my table estoque where I bring the supply model , your current quantity and what your quantity minima in the inventory, for this I made query as follows:

SELECT codigosuprimento, suprimento, count (codigosuprimento) quantidade, estoqueminimo
FROM public.estoque, public.suprimento where usado = '0' and 
public.estoque.codigosuprimento = public.suprimento.codigo group by codigosuprimento, suprimento, estoqueminimo order by suprimento;

It is possible to perform a calculation on this query to bring the balance of this supply, for this I would make the account quantidade - estoqueminimo , is it possible?

    
asked by anonymous 13.10.2017 / 16:02

1 answer

1

I discovered how to return what I need, I just needed to change a part of query , in the end it looks like this:

SELECT codigosuprimento, suprimento, count (codigosuprimento) quantidadeAtual, estoqueminimo, (count (codigosuprimento) - estoqueminimo) quantidadeSaldo
    FROM public.estoque, public.suprimento where usado = '0' and 
    public.estoque.codigosuprimento = public.suprimento.codigo group by codigosuprimento, suprimento, estoqueminimo order by suprimento;

Thanks for everyone's help

    
13.10.2017 / 16:18