Advertisement
Guest User

AppCasa

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