SQL · Robinhood · Medium
You are given two tables: Users(user_id INT PRIMARY KEY, name VARCHAR(50), country VARCHAR(2)) Transactions(transaction_id INT PRIMARY KEY, from_user_id INT, to_user_id INT, amount INT, created_at TIMESTAMP) Some transactions use a negative amount to indicate that the raw direction is reversed. The normalized rule is: If $$\mathrm{amount} \ge 0$$, the initiator is from_user_id and the beneficiary is to_user_id. If $$\mathrm{amount} < 0$$, the initiator is to_user_id and the…
Checking your access…