HI,
I'm trying to add the following SQL to a query:
LEFT JOIN (SELECT Min(start_time) min_start, user_id
FROM events where active is true
GROUP BY user_id) e1 ON users.id = e1.user_id
LEFT JOIN events e2 ON e1.user_id = e2.user_id AND e1.min_start =
e2.start_time
The following gets me close, but puts quotes around the first join which
causes an error.
.left_join('
(SELECT Min(start_time) min_start, user_id
FROM events where active is true
GROUP BY user_id) e1 ON users.id = e1.user_id')
.left_join('events',
'e1.user_id = e2.user_id AND e1.min_start = e2.start_time',
{table_alias: 'e2'})
Is there a way to do this?
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/sequel-talk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.