Okay.
I've been put on a project at work, and though I've got some SQL skills, they are very rusty.
One of the scenarios at work has left me with a number of tables with values I need to sum up. They are not linked either, but the order is the same across all the tables.
Basically, I would like to take this two tables:
CASH TABLE
London 540
France 240
Belgium 340
CHEQUE TABLE
London 780
France 490
Belgium 230
To get an output like this to feed into a graphing application:
London 1320
France 730
Belgium 570
Please help.
'And so on and so forth.
you can also try this in sql-server !!
demo
or try using sum,union
For your current structure, you could also try the following:
I think I prefer a union between the two tables, and a group by on the country name as mentioned above.
But I would also recommend normalising your tables. Ideally you'd have a country table, with Id and Name, and a payments table with: CountryId (FK to countries), Total, Type (cash/cheque)