tx-oliveira Posted September 14, 2023 at 04:03 PM Report Share #631806 Posted September 14, 2023 at 04:03 PM Boa tarde, Estou a fazer uma query com inner join de várias tabelas, preciso de fazer uma soma dessa coluna. Como fazer ? Obrigado Link to comment Share on other sites More sharing options...
Solution M6 Posted September 15, 2023 at 08:15 AM Solution Report Share #631811 Posted September 15, 2023 at 08:15 AM Usas o SUM e fazes um Group By. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
tx-oliveira Posted September 15, 2023 at 02:45 PM Author Report Share #631814 Posted September 15, 2023 at 02:45 PM 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 More sharing options...
M6 Posted September 18, 2023 at 08:10 AM Report Share #631826 Posted September 18, 2023 at 08:10 AM O group by tem de incluir todos os campos que estão no select exceto os que são agrupados. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now