-4

I'm kind new in this forum but I'm stuck in a problem and I need our help. I Have one table with several lines where each line represent one project, then in another table I'll have many tasks that need to be done in each project, each task would have a percentage of at what level is, and the result of this two tables is one table where I'll have the process Id and also the percentage of accomplished with the average of the last entries of every tasks values.

I can't figured out the query that needs to be done to have the result that I want.

Can anyone help me? You can see follow the link bellow to see tables and the result that I want.

https://lh5.googleusercontent.com/YHy6JU2SDh2qOJ_AWufYF0dflMg_yWASrBL8U9qstxtVc9pF7c0UeYfeg86eNP-jdWOfjicpFmWpkJc=w1256-h803 Table iamges

TimoStaudinger
  • 41,396
  • 16
  • 88
  • 94
  • the image of Result: QUERY has real values? or you used some random values? I told it to you, because if i understand it propertly, the average for Idproceso=2 is 71.25 instead of 90 u said in the result table. – Tirma May 26 '15 at 14:42
  • Yes it has real values, average is done using the last entree of each Id_tarefa where "estado" is the percentage of each one. – Marco Ferreira May 26 '15 at 15:39

1 Answers1

0

I didnt understand the colors of rows you used, but with your description, i think this is the query you are looking for:

select P.id_Proceso, P.SubProceso, avg(R.estado)
from Processos P 
join Registros R
on P.ID = R.Id_processo
group by P.id_Proceso, P.SubProceso
Tirma
  • 664
  • 5
  • 16
  • Hi Tirma,Yes is something like that, is just missing one thing in your code that is related with the colors in the rows. For example I have 3 Id_processos that is related with the "table:Processos", then I have Id_tarefa that is equal to my tasks where each task has its own Id, then I have "estado" who is my percentage of each task. In the result I'll have the average of the ID 1 betwen "Id_tarefa" 1 and 50 who is 35 because I only have one entree of the "task 1= 60" and the last entree of the "task 50 = 10", in another "Id_processo 3" I have task 49,47,45,50 and the result is 71.25 – Marco Ferreira May 26 '15 at 15:35
  • OK... nice ;) If u solved it, please post the complete query, so other people can see it. Thanks! ;) – Tirma May 26 '15 at 16:27