Add values from several columns from two different tables?


So, I have two tables, exam1 and exam2 which looks like these:

sid physics chemistry biology
3 80 60 40

sid physics chemistry biology
3 40 50 70

I want to find the sum of items from both tables (exam1 and exam2), like this

table: total
sid physics chemistry biology
3 120 110 110

I wont always have to find total of all courses (physics, chemistry, biology), sometimes I may want to find sum of only two, one of all three subjects, so this is really a variable.

Since I program from VB.NET, the list of courses to be totaled can be specified by a user at run time and is kept in a variable say, "courses", so sometimes courses= (physics,chemistry,biology) sometimes courses=(physics,chemistry) and so on.

How can I then find a total of courses that the user selects? (still total of courses in exam1+exam2 tables)


Please Login to post your reply or start a new topic