Jump to content

Query com inner join e fazer soma


tx-oliveira
Go to solution Solved by M6,

Recommended Posts

de estou a usar isso e não estou a conseguir, como se faz sabe ? 

 

SELECT OPE.MFGNUM_0'NUMERO ORDEM FABRICO', OPETRK.OPENUM_0 'OPERACAO' ,OPE.MFGFCY_0 'SOCIEDADE', ITM.ITMREF_0 'ARTIGO',ITM.YITMPAI_0 'ARTIGO PAI',
OPE.CPLWST_0 'POSTO REALIZADO', SUM( OPE.CPLQTY_0) 'QUANTIDADE REALIZADA' ,OPETRK.CPLQTY_0 'QUANTIDADE REALIZADA NO SEGUIMENTO',
CONVERT(CHAR, OPE.OPEEND_0,103) 'DATA FIM DA OF', CONVERT(char, OPETRK.DACDAT_0,103) 'DATA DO REGISTO DO SEGUIMENTO', OPETRK.CPLOPETIM_0 'TEMPO OPERADO REALIZADO'
FROM BD.MFGOPE AS OPE
INNER JOIN BD.MFGOPETRK AS OPETRK ON OPE.MFGNUM_0=OPETRK.MFGNUM_0
INNER JOIN BD.MFGITM AS ITM ON ITM.MFGNUM_0=OPE.MFGNUM_0
WHERE OPE.MFGFCY_0='PT2' AND OPE.CPLWST_0='MAQ3' AND  OPE.OPESTR_0 BETWEEN '2023-09-01' AND GETDATE()
--ORDER BY OPE.OPESTR_0 DESC 
GROUP BY OPE.CPLQTY_0 
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.