I've got a table with multiple dated snapshots per user and a table with the latest date of the snapshot for each user (generated via a query).
I've tried a number of variations to get a simple join of the two to work but I'm having no luck. I want to select all records from the snapshots table that match the user id and date from the other table.
I've gota variety of errors, but this is the latest (sub-selects and renames were done to debug what field might be causing the problem):
SELECT t1.uuid, t1.username, t1.d
FROM (SELECT uuid, username, date AS d FROM [Activity.user_snapshots]) as t1
JOIN EACH (SELECT uuid, date AS dg FROM [Activity.latest_snapshots]) as t2
ON t1.uuid = t2.uuid AND t1.d = t2.dg;
The error response that I get in this case is:
Error: Field 'dg' not found in table '__S0'.
When I've tried the much more straight-forward query:
SELECT t1.uuid, t1.username, t1.date
FROM [Activity.user_snapshots] as t1
JOIN EACH [Activity.latest_snapshots] as t2
ON t1.uuid = t2.uuid AND t1.date = t2.date;
I get this error:
Error: Field date from table __S0 is not a leaf field.
Any ideas?