I'm trying to get a list of all the clicks and sales associated with an account, with both tables having the account ID as an index. Right now I have:
SELECT ACCOUNT, SUM(REVENUE) AS R, COUNT(*) AS SALES
FROM CONVERSIONS
WHERE ACCOUNT = ? AND TIME BETWEEN ? AND ? GROUP BY ACCOUNT
AND
SELECT ACCOUNT, COUNT(DISTINCT BIN_IP) AS CLICKS
FROM CLICKS
WHERE ACCOUNT = ? AND TIME BETWEEN ? AND ? GROUP BY ACCOUNT
That gives me both lists, but then I have to do a ton of array manipulation to get them to uniquely line up. Trying to see if there's a way to join both queries, but thus far everything I've tried has failed.
Edit: For clarity, my issue with every join I've tried is I lose the case that theres sales and no clicks, or clicks and no sales. Joining them and checking that the table.ACCOUNT = table2.ACCOUNT only works if there's both clicks and sales present. This is essentially the part of the puzzle I'm struggling with.