Skip to content

Instantly share code, notes, and snippets.

@tdowling
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save tdowling/9666572 to your computer and use it in GitHub Desktop.

Select an option

Save tdowling/9666572 to your computer and use it in GitHub Desktop.
option transactions on the same day
SELECT aa1.activity,
aa2.activity,
aa1.date,
aa1.account_id
FROM account_activities aa1
RIGHT JOIN account_activities aa2 ON aa1.account_id = aa2.account_id
AND aa1.date = aa2.date
AND aa1.fund_id = aa2.fund_id
AND aa1.activity <> aa2.activity
JOIN funds f ON aa1.fund_id = f.id
WHERE f.symbol LIKE '%|%';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment