on 03-05-2020 12:23 PM
Bom dia a todos!
Gostaria de uma ajuda no problema abaixo:
1-Criei um campo de usuário para mostrar nas linhas dos documentos de marketing a informação do custo do item de acordo com o depósito.
2-Depois criei uma consulta formatada que lê o código do item e o depósito selecionado no documento e verifica na OITW o Preço Médio.
Porém, a consulta não está funcionando, o que será que fiz de errado na sintaxe?
COMANDO SQL
SELECT DISTINCT T0.AvgPrice
FROM OITW T0
LEFT JOIN QUT1 T1 ON T1.ITEMCODE = T0.ItemCode
INNER JOIN OQUT T2 ON T2.DocEntry = T1.DocEntry
WHERE T1.ITEMCODE = $[S38.1.0] AND T1.WhsCode = T0.WhsCode
Boa tarde,
Basta substituir a letra 'S' pelo caractere '$' na cláusula WHERE:
$[S38.1.0] para $[$38.1.0]
att,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jose,
you don't need the OQUT.
That should be enough
SELECT T0.AvgPrice FROM OITW T0 WHERE T0.ItemCode = $[S38.1.0] AND T0.WhsCode = $[$38.24.0]
Get the price from the Warehouse according to the line from the document.
If you need the default Whs you need to join on OITM DfltWhs.
If needed you can cast the price on your needs
regards Lothar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Código Revisado após identificarmos inconssistencia no código anterior...
---
SELECT
'R$ ' + REPLACE(REPLACE(REPLACE(CONVERT(varchar, CAST(T2.AvgPrice AS money), 1),',', '_'), '.', ','), '_', '.')
FROM QUT1 T0
INNER JOIN OQUT T1 ON T1.DocEntry = T0.DocEntry
RIGHT JOIN OITW T2 ON T2.ItemCode = T0.ItemCode AND T0.WhsCode = T2.WhsCode
WHERE T0.ITEMCODE = $[$38.1.0] AND T0.WhsCode = T2.WhsCode AND T0.DOCENTRY = $[$8.1.0]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Código Revisado após identificarmos inconssistencia no código anterior...
---
SELECT
'R$ ' + REPLACE(REPLACE(REPLACE(CONVERT(varchar, CAST(T2.AvgPrice AS money), 1),',', '_'), '.', ','), '_', '.')
FROM QUT1 T0
INNER JOIN OQUT T1 ON T1.DocEntry = T0.DocEntry
RIGHT JOIN OITW T2 ON T2.ItemCode = T0.ItemCode AND T0.WhsCode = T2.WhsCode
WHERE T0.ITEMCODE = $[$38.1.0] AND T0.WhsCode = T2.WhsCode AND T0.DOCENTRY = $[$8.1.0]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Paulo Sanches, boa tarde!
É esta mesma a solução para o problema!
Obrigado pela ajuda!
Att
José Silva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
105 | |
9 | |
7 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.