Click here to Skip to main content
15,892,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There are 2 tables recharge_info,customer_info.


now i want the details of customer along with total amt of recharge done till date by that customer.

customer_info
name | email | contactno.| customerid|

recharge_info
rid|servicetype|email|amt|

fields required

name|email|contactno|email|total_amt|
Posted

1 solution

SQL
select name, email, contactno, sum(amt) as total_amt
from customer_info 
inner join recharge_info on rid = customerid
group by name, email, contactno

or
SQL
select 
 ci.name, 
 ci.email, 
 ci.contactno, 
 (select sum(ri.amt) from recharge_info ri where ri.rid = ci.customerid) as total_amt
from customer_info ci
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900