I have the following Query
:
SELECT
public.suprimento.suprimento,
public.estoque.numeroserie,
public.fornecedor.nome as fornecedor,
public.estoque.data as dataentrada,
public.estoque.numeronotafiscal,
public.empresa.nome as empresa,
public.entrega.data as datasaida,
public.entrega.notafiscalhss,
public.entrega.usuario,
public.entrega.usuariohss,
public.lotesretornosuprimento.dataretorno,
public.lotesretornosuprimento.laudo,
public.lotesgarantiastatus.numeroserieretornado
FROM
public.estoque,
public.suprimento,
public.fornecedor,
public.entregaitem,
public.entrega,
public.empresa,
public.lotesretornosuprimento,
public.lotesgarantiastatus
where
public.suprimento.codigo = public.estoque.codigosuprimento and
public.estoque.codigofornecedor = public.fornecedor.codigo and
public.entregaitem.codigoestoque = public.estoque.codigo and
public.entregaitem.codigoentrega = public.entrega.codigo and
public.empresa.codigo = public.entrega.codigoempresa and
public.lotesretornosuprimento.numeroserie = public.estoque.numeroserie and
public.lotesgarantiastatus.numeroserieenviado = public.estoque.numeroserie
That returns me the whole course of the supply from the moment it is bought until the return to our supplier for correct disposal or for guarantee, my need however is to also display the supplies that way bought but still were not sent to any client or returned to the vendor, in the way I mounted the Query
I only select the supplies that had the complete track:
Purchase - > Sale - > Return Supplier
It is possible to adapt this Query
so that it also returns the following situations:
Purchase - > Sale
And also when the supply is only purchased:
Buy