I have a table which has columns:
txn_id
from_user_id
to_user_id
price
I want a query that produces two rows for each source row. The output would look like:
focal_user_id
(new)txn_id
from_user_id
to_user_id
price
The focal_user_id
value is generated from from_user_id
for the first row output, and generated from to_user_id
for the second row.
I need to do this in SQL rather than code because then I can make use of WHERE
and LIMIT
, as well as do some joins based on the new focal_user_id
column.