daily pastebin goal
19%
SHARE
TWEET

Untitled

a guest Oct 12th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT estabelecimento.nome AS estabelecimento
  2. , notafiscal.dtemissao
  3. , notafiscal.dtentrega
  4. , notafiscal.numpedido
  5. , notafiscal.tipoparceiro AS tipoparceiro
  6. , (CASE WHEN notafiscal.tipoparceiro = 'C' THEN cliente.nome WHEN tipoparceiro = 'F' THEN fornecedor.nome WHEN tipoparceiro = 'E' THEN e.nome ELSE NULL END) AS parceiro
  7. , notafiscal.numnotafis AS notafiscal
  8. , notafiscal.serie
  9. , (natoperacao.natoperacao || ' - ' || natoperacao.descricao) AS natoperacao
  10. , notafiscal.totalliquido
  11. , notafiscal.status
  12. FROM notafiscal
  13. LEFT JOIN cliente ON (notafiscal.tipoparceiro = 'C' AND notafiscal.codparceiro = cliente.codcliente)
  14. LEFT JOIN fornecedor ON (notafiscal.tipoparceiro = 'F' AND notafiscal.codparceiro = fornecedor.codfornec)
  15. LEFT JOIN estabelecimento e ON (notafiscal.tipoparceiro = 'E' AND notafiscal.codparceiro = e.codestabelec)
  16. INNER JOIN estabelecimento ON (notafiscal.codestabelec = estabelecimento.codestabelec)
  17. INNER JOIN natoperacao ON (notafiscal.natoperacao = natoperacao.natoperacao)
  18. WHERE notafiscal.operacao NOT IN ('CP','TE')
  19. AND notafiscal.codestabelec = 2
  20. ORDER BY notafiscal.dtentrega, estabelecimento.nome, notafiscal.numnotafis
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top