I have two tables user_detail, department so i want to get the sum of amount from user_detail table base on the department.
Both tables having did column. totalam is the new column for the total amount that will come after adding the amount based on did on user detail.
select department.department, sum(user_detail.amount) as totalam from user_detail inner join department on department.did=user_detail.did group by department.did,department.department;
Both tables having did column. totalam is the new column for the total amount that will come after adding the amount based on did on user detail.
select department.department, sum(user_detail.amount) as totalam from user_detail inner join department on department.did=user_detail.did group by department.did,department.department;
Tags:
Basic