So is Name the same in each table? ie is it referring to the same thing? If so, you can join the tables on that field like so:
select t1.Name, t1.amount, t2.nominal
from Table1 t1
left outer join Table2 t2 -- left outer join will return all results even if there is no entry in table2 for the corresponding record in table1
on t1.Name = t2.Name -- specifies the column(s) to join on
The above query gives you the Name, amount and nominal columns from your two tables.
Now the SUM() function is used to sum a set of values, and you can use a GROUP BY clause to tell how to sum the values. So the following query will sum the amount column from table 1 for each Name in table 1:
select Name, SUM(amount)
group by Name
Ok, there's two pretty big clues as to what you need to do, have a go at combining what I have said and post back if you get stuck.
no the name not to refer to the same thing because
the name in table1 is for the name of fruits ,the name of table2 is the name of drinks.I want to know how much
money spend for both of them in a month.
If you're in one of those predicaments where cls.__private attributes just aren't enough since they can easily be accessed through inst._cls__private, and you need something a little more secure, here's ...