I want to select a list of all unique addresses and value from two tables: inputs and outputs (field “addresses” and “value” in two tables).
I need to make a query that retrieves all addresses and value from table inputs, but from value we need to subtract value from table outputs if the addresses matches in both tables. The result should be a unique list of addresses and the final value of value (inputs_value – outputs_value).
Addresses can be duplicated in tables, but they can have different value. You need to process each of them in the query.
You can take one addresses from the table inputs, get all value by it. Do the same for the second table outputs. And finally subtract the difference value between the tables and write the result to result_value.
As a result, I’d like to get a list of addresses Dogecoin and the final balance for them (list addresses with balance > 0).
The table inputs stores addresses with incoming cryptocurrency transactions Dogecoin. One address can receive replenishment of coins, which are reflected in the field value. This is an incoming transaction. The table outputs stores addresses if they sent coins to other addresses (outgoing transaction).
link table inputs
link table outputs