MySQL select and join -


i have 2 tables customers , cdr_customers(these examples of fields):

mysql> select i_customer,i_parent customers i_parent = 234 limit 1\g *************************** 1. row *************************** i_customer: 266 i_parent: 234  mysql> select i_customer, charged_amount, i_service cdr_customers i_service=4 limit 1\g *************************** 1. row ***************************     i_customer: 64 charged_amount: 35.00000      i_service: 4 

what want achieve make query selects total "charged amount" "customers" has same i_parent , i_service cdr_customers table = 4;

i've tried write query, not seem correct:

mysql> select sum(a.charged_amount), b.i_parent cdr_customers join customers b on a.i_customer=b.i_customer b.i_parent=234 , i_service = 4; +-----------------------+----------+ | sum(a.charged_amount) | i_parent | +-----------------------+----------+ |                  null |     null | +-----------------------+----------+ 

could please advice?


Comments