Skip to content
Advertisement

Calculating values from two tables where one has key in header and one has it in column values

I have a simple problem that I dont know how to solve in sql.

I have two tables, cost :

second table: income

Now i want to get a result that substract for each party A, B, C the income-cost and finds the net value. I cannot compare the column header to column value. I am quite new to this, so I am struggling quite a lot. There should be really easy way of doing this.

I created the ‘cost’ table by

may be there is clever way of creating this table in the same formate as income table that would make it easier to compare? I will appreciate any suggeestion on any of the two fronts. Thanks a lot!

Advertisement

Answer

You can compare, using case:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement