Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT codepto,departamento,codprod,descricao,embalagem,unidade,codauxiliar,loja,preco,imagem,estoque,escala
  2. FROM
  3. (
  4. SELECT ROWNUM seq, a.*
  5. FROM
  6.  (
  7. SELECT * FROM (
  8. SELECT d.CODEPTO, d.descricao DEPARTAMENTO, p.CODPROD, NVL(p.DESCRICAO7,p.descricao) DESCRICAO,
  9. NVL(p.descricaodinamica,p.EMBALAGEM) EMBALAGEM, p.UNIDADE, p.CODAUXILIAR,
  10. t.numregiao LOJA,
  11. NVL((SELECT pcp.precofixo
  12. FROM pcprecoprom pcp
  13. WHERE TRUNC(TO_DATE(SYSDATE)) BETWEEN pcp.dtiniciovigencia AND pcp.dtfimvigencia
  14. AND pcp.codprod = p.codprod
  15. AND pcp.numregiao = t.numregiao
  16. AND pcp.codcli IS NULL
  17. AND pcp.precofixo IN (SELECT MIN(pcx.precofixo)
  18.                       FROM pcprecoprom pcx
  19.                       WHERE pcx.codprod   = pcp.codprod
  20.                       AND   pcx.numregiao = pcp.numregiao
  21.                       AND   pcx.codcli IS NULL
  22.                       AND   TRUNC(TO_DATE(SYSDATE)) BETWEEN pcx.dtiniciovigencia AND pcx.dtfimvigencia )
  23.                       GROUP BY pcp.precofixo),t.pvenda1) preco,
  24. 'S:\winthor\sistema\Fotos\'||p.codprod||'.png' IMAGEM, e.qtestger estoque, p.numerosseriecontrolados escala
  25. from pcprodut p, pcdepto d, pctabpr t, pcest e, pcprodfilial pf
  26. where p.codepto = d.codepto
  27. and   p.codprod = t.codprod
  28. and   p.codprod = e.codprod
  29. and   t.numregiao = e.codfilial
  30. and   p.codprod = pf.codprod
  31. and   t.numregiao = pf.codfilial
  32. and   t.numregiao between 5 and 39
  33. and   t.numregiao not in (1,2,3,4,6)
  34. and   (e.qtestger-e.qtindeniz) > (e.qtgirodia*2)
  35. and   p.dtexclusao is null
  36. and   p.embalagem <> 'KG'
  37. and   p.embalagem <> '25KG'
  38. and   p.descricao not like '%(MC)%'
  39. and   p.descricao not like 'PD%'
  40. and   p.descricao not like 'LJ%'
  41. and   p.codfornec not in (101385)
  42. and   p.codprod  not in (647320,647344,647460,647469,647110,647468)
  43. and   p.codprod not in (select codprod
  44.                        from pcprodut
  45.                        where descricao like '%GELADO%'
  46.                        and descricao not like '%CONGELADO%'
  47.                        and dtexclusao is null)
  48. and   p.codepto not in (5,12,10000,10003,10002)
  49. and   p.codsec not in (253,211,204,14,226,55,25)
  50. and   p.codcategoria not in (55)
  51. and   p.codsubcategoria not in (88,245,48)
  52. and   pf.foralinha = 'N'
  53. and   p.obs2 not like '%FL%'
  54. and   t.pvenda1 > 0
  55. and e.codfilial in (5,7,8,9,11,12,13,14,15,16,17,18,19,22,23,24)
  56. group by d.CODEPTO, d.descricao, p.CODPROD, p.DESCRICAO7,p.descricao,
  57. p.descricaodinamica,p.EMBALAGEM, p.UNIDADE, p.CODAUXILIAR,
  58. t.numregiao, t.pvenda1, e.qtestger, p.numerosseriecontrolados
  59.  
  60. union all
  61.  
  62. select d.CODEPTO, d.descricao DEPARTAMENTO, p.CODPROD, nvl(p.DESCRICAO7,p.descricao) DESCRICAO,
  63. nvl(p.descricaodinamica,p.EMBALAGEM) EMBALAGEM, p.UNIDADE, p.CODAUXILIAR,
  64. t.numregiao LOJA,
  65. nvl((select pcp.precofixo
  66. from pcprecoprom pcp
  67. where trunc(to_date(sysdate)) between pcp.dtiniciovigencia and pcp.dtfimvigencia
  68. and pcp.codprod = p.codprod
  69. and pcp.numregiao = t.numregiao
  70. and pcp.codcli is null
  71. and pcp.precofixo in (select min(pcx.precofixo)
  72.                      from pcprecoprom pcx
  73.                      where pcx.codprod   = pcp.codprod
  74.                      and   pcx.numregiao = pcp.numregiao
  75.                      and   pcx.codcli is null
  76.                      and   trunc(to_date(sysdate)) between pcx.dtiniciovigencia and pcx.dtfimvigencia )
  77.                      group by pcp.precofixo),t.pvenda1) preco,
  78. 'S:\winthor\sistema\Fotos\'||p.codprod||'.png' IMAGEM, e.qtestger estoque, p.numerosseriecontrolados escala
  79. from pcprodut p, pcdepto d, pctabpr t, pcest e, pcprodfilial pf
  80. where p.codepto = d.codepto
  81. and   p.codprod = t.codprod
  82. and   p.codprod = e.codprod
  83. and   t.numregiao = e.codfilial
  84. and   p.codprod = pf.codprod
  85. and   t.numregiao = pf.codfilial
  86. and   t.numregiao between 5 and 39
  87. and   t.numregiao not in (1,2,3,4,6)
  88. and   p.dtexclusao is null
  89. and   p.descricao not like '%(MC)%'
  90. and   p.descricao not like 'PD%'
  91. and   p.descricao not like 'LJ%'
  92. and   p.embalagem <> '25KG'
  93. and   p.codfornec not in (101385)
  94. and   p.codprod  not in (647320,647344,647460,647469,647110,647468)
  95. and   p.codprod not in (select codprod
  96.                        from pcprodut
  97.                        where descricao like '%GELADO%'
  98.                        and descricao not like '%CONGELADO%'
  99.                        and dtexclusao is null)
  100. and   p.codepto not in (5,12,10000,10003,10002)
  101. and   p.codsec not in (253,211,204,14,226,55,25)
  102. and   p.codcategoria not in (55)
  103. and   p.codsubcategoria not in (88,245,48)
  104. and   p.embalagem = 'KG'
  105. and   pf.foralinha = 'N'
  106. and   p.obs2 not like '%FL%'
  107. and   t.pvenda1 > 0
  108. and   e.qtestger <> 0
  109. and   (nvl(e.qtvendmes,0) + nvl(e.qtvendmes1,0) + nvl(e.qtvendmes2,0) + nvl(e.qtvendmes3,0)) <> 0
  110. and e.codfilial in (5,7,8,9,11,12,13,14,15,16,17,18,19,22,23,24)
  111. group by d.CODEPTO, d.descricao, p.CODPROD, p.DESCRICAO7,p.descricao,
  112. p.descricaodinamica,p.EMBALAGEM, p.UNIDADE, p.CODAUXILIAR,
  113. t.numregiao, t.pvenda1, e.qtestger, p.numerosseriecontrolados
  114.  
  115. ) app
  116. order by app.loja, app.departamento, app.descricao
  117.  ) a
  118. order by a.loja, a.departamento, a.descricao
  119. ) b
  120. where b.seq>=  ( 1 * 10 ) - 10
  121.  and b.seq<     1 * 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement