question

Gelain avatar image
Gelain asked

Separate sales codes by company

Hi, In case of two companies, code 1 and code 2. Both have a customer with the same code. How to query only sales of customers in company 1? Company CodeCustomer CustomerName Value 1 980 Paulo Silva 200,00 2 980 Paulo Silva 150,00 Thank you. SELECT D.CODCOLIGADA AS 'COLIGADA CLIENTE' , A.CODFILIAL , A.CODTMV , A.STATUS , D.PESSOAFISOUJUR , B.NOME , A.DATAEMISSAO , A.NUMEROMOV , A.CODCFO , D.NOMEFANTASIA , C.VALORBRUTOITEM , E.NOMEFANTASIA AS NOMEITEM , A.USUARIOCRIACAO FROM TMOV AS A INNER JOIN ttmv AS B ON A.CODCOLIGADA = B.CODCOLIGADA AND A.CODTMV = B.CODTMV INNER JOIN TITMMOV AS C ON A.CODCOLIGADA = C.CODCOLIGADA AND A.IDMOV = C.IDMOV INNER JOIN FCFO AS D ON A.CODCFO = D.CODCFO INNER JOIN TPRODUTO AS E ON C.IDPRD = E.IDPRD WHERE A.CODTMV IN ( '2.2.01', '2.2.02', '2.2.03', '2.2.04', '2.2.05', '2.2.06', '2.2.07', '2.2.08', '2.2.12', '2.2.13', '2.2.14', '2.2.15', '2.2.16', '2.2.17', '2.2.18', '2.2.19', '2.2.20', '2.2.21', '2.2.24', '2.2.25', '2.2.26', '2.2.27', '2.2.28', '2.2.29', '2.2.30', '2.2.31', '2.2.32', '2.2.33' ) AND A.DATAEMISSAO >= '2016-01-01' AND A.NUMEROMOV = '21067'
filter
1 comment
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

It could be as simple as adding a where clause `and Company = 1` ?
2 Likes 2 ·

1 Answer

· Write an Answer
sriramachyu avatar image
sriramachyu answered
try adding company = 1 in the where clause
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.