Last active
July 15, 2018 11:14
-
-
Save danabrey/8b2bc6c4783fe8ddfaf8a2be4ac51b3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT uts.user_id, MIN(uts.ts) as earliest_action FROM ( | |
SELECT user_id, MIN(placed) as ts FROM ADS WHERE user_id > 0 GROUP BY user_id UNION ALL | |
SELECT user_id, MIN(placed_on) as ts FROM reviews WHERE user_id > 0 GROUP BY user_id UNION ALL | |
SELECT EVENTS_user_xref.user_id as user_id, MIN(EVENTS.placed_time) as ts FROM EVENTS JOIN EVENTS_user_xref ON EVENTS.id = EVENTS_user_xref.event_id WHERE EVENTS_user_xref.user_id > 0 AND EVENTS.placed_time > 0 GROUP BY EVENTS_user_xref.user_id UNION ALL | |
SELECT EVENTS_user_xref.user_id as user_id, MIN(EVENTS_archive.placed_time) as ts FROM EVENTS_archive JOIN EVENTS_user_xref ON EVENTS_archive.id = EVENTS_user_xref.event_id WHERE EVENTS_user_xref.user_id > 0 AND EVENTS_archive.placed_time > 0 GROUP BY EVENTS_user_xref.user_id UNION ALL | |
SELECT user_id, UNIX_TIMESTAMP(MIN(time)) as ts FROM user_action_log WHERE time > 0 AND user_id > 0 GROUP BY user_id UNION ALL | |
SELECT user_id, MIN(time) as ts FROM email_mask_log WHERE time > 0 AND user_id > 0 GROUP BY user_id | |
) uts | |
GROUP BY user_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment