bronckhorst Posted January 12, 2017 at 04:34 PM Report Share #601975 Posted January 12, 2017 at 04:34 PM Boa tarde. Estou com dificuldades a juntar o resultado de duas consultas em uma só. As minhas duas consultas devolvem algo do género: Ano Semana Secção Descontos 2016 52 930 - IT&COM Geral 120 Ano Semana Secção HE 2016 52 301 - ENG TN 75 2016 52 931 - IT&COM TN 45 Como é posso fazer para obter um resultado do género: Ano Semana Secção HE Descontos 2016 52 301 - ENG TN 75 0 2016 52 931 - IT&COM TN 45 0 2016 52 930 - IT&COM Geral 0 120 Obrigado. Link to comment Share on other sites More sharing options...
HappyHippyHippo Posted January 12, 2017 at 04:51 PM Report Share #601976 Posted January 12, 2017 at 04:51 PM certo, e qual é o modelo das tabelas dos quais resultam os dados apresentados ? IRC : sim, é algo que ainda existe >> #p@p Portugol Plus Link to comment Share on other sites More sharing options...
bronckhorst Posted January 12, 2017 at 05:02 PM Author Report Share #601977 Posted January 12, 2017 at 05:02 PM Boa tarde. As querys das quais resultam os dados apresentados são as seguintes: WITH HORASEXTRATRABALHADAS AS ( SELECT DATEPART(yy, MOV.Data) AS 'Ano', DATEPART(wk, MOV.Data) 'Semana', SEC.Designacao AS 'Seccao', SUM(MOV.MinutosAtribuidos) AS 'HE' FROM GESPIC.MovimentosHE_BH MOV, TimeNet.dbo.t_funcionarios FUNC, TimeNet.dbo.t_seccoes SEC WHERE MOV.MinutosAtribuidos > '0' AND MOV.IdFuncionario = FUNC.codigo AND FUNC.seccao = SEC.ID GROUP BY DATEPART(yy, MOV.Data), DATEPART(wk, MOV.Data), SEC.Designacao ), DESCONTOSBH AS ( SELECT DATEPART(yy, MOV.Data) AS 'Ano', DATEPART(wk, MOV.Data) 'Semana', SEC.Designacao AS 'Seccao', SUM(MOV.MinutosAtribuidos)* -1 AS 'Descontos' FROM GESPIC.MovimentosHE_BH MOV, TimeNet.dbo.t_funcionarios FUNC, TimeNet.dbo.t_seccoes SEC WHERE MOV.MinutosAtribuidos < '0' AND MOV.IdFuncionario = FUNC.codigo AND FUNC.seccao = SEC.ID GROUP BY DATEPART(yy, MOV.Data), DATEPART(wk, MOV.Data), SEC.Designacao ) Link to comment Share on other sites More sharing options...
M6 Posted January 13, 2017 at 03:15 PM Report Share #601992 Posted January 13, 2017 at 03:15 PM Tens de fazer um join entre ambas as queries por ano, semana e seccao e mostrares as colunas que quiseres do resultado desse join. 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