Advertisement
Guest User

Renato

a guest
Mar 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.     pd.id, pd.nom_produto,
  3.     to_char(v.dat_venda, 'DD/MM/YYYY') AS data_geracao,
  4.     v.ind_status_faturamento,
  5.     SUM (v.vlr_venda_abatido) AS total,
  6.     COUNT (v. ID) AS qtdVenda,
  7.     cl.id_empresa, e.nom_empresa,
  8.     md.nom_marca,v.id_integrador
  9. FROM
  10.     n2.tb_ciclo_venda cv,
  11.     n2.tb_ponto_venda pv,
  12.     n2.tb_cliente cl,
  13.     n2.tb_venda v,
  14.     n2.tb_produto_distribuidor pd,
  15.     n2.tb_regional_marca_distribuidor rmd,
  16.     n2.tb_marca_distribuidor md,
  17.     admin.tb_empresa e
  18. WHERE
  19.     cv.id_ponto_venda = pv. ID
  20. AND pv.id_cliente = cl. ID
  21. AND v.ind_status_faturamento IN ('P', 'A')
  22. AND v.dat_venda >= '2016-12-01 00:00:00'
  23. AND v.id_cobranca_vinculada = cv. ID
  24. AND v.id_produto_distribuidor = pd. ID
  25. AND pd.id_regional_marca_distribuidor = rmd. ID
  26. AND rmd.id_marca_distribuidor = md. ID
  27. and e.id = cl.id_empresa
  28. AND v.ind_faturada = 'S'
  29. AND v.vlr_venda_abatido > 0
  30. GROUP BY
  31.     pd.id, pd.nom_produto
  32.     , v.dat_venda,
  33.     v.ind_status_faturamento,
  34. cl.id_empresa,e.nom_empresa,md.nom_marca,v.id_integrador
  35. ORDER BY
  36.     v.dat_venda,
  37.     v.ind_status_faturamento;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement