Thursday 15 August 2013

mysql - Select, Join left, Union. Help me, -


I have 3 tables flowing and I try to create a query to show results. But it only shows half

  project -------------- ID name -------------- 1 project 1 2 Project 2 3 Project 3 4 Project 4 5 Project 5 6 Project 6 Pj_rp ----------------------------- ID id_pj id_rp - ------ --------------------- 1 1 2 2 2 3 1 3 4 2 4 5 1 5 6 3 6 Report ----- ----- ----- ID fee -------------- 1 200 2 200 3 400 4 400 5 400 6 400   

Results me Want to receive

  ** results ** -------------------- Project SUM (fee) ------ ------ -------- Project 1 1000 Project 2 600 Project 3 400 Proz I have created a Falling Query but this is incorrect  
  SELECT a.name, c.Fee from the project left one. Join Pj_rp b ON (a.id = b.id_pj) LEFT JOIN report c ON (b.id_rp = c.id) by group a.tongmucdautuduan_usd   

I do not know which Can I help in solving?

Thank you!

  SELECT a.name "project", join a left side from sum (c.fee) project Pj_rp b ON (a.id = b.id_p) J) LEFT JOIN report c ON (b.id_rp = c.id) group a.name    

No comments:

Post a Comment