Je suis en train de traduire l'instruction SQL suivante à Esqueleto:Esqueleto: rejoignez le sous-requête (en utilisant subList_select)
SELECT id, task_id, author_id
FROM scenario
INNER JOIN (SELECT task_id as tId, author_id as aId, MAX(last_update) as lastUp
FROM scenario
GROUP BY task_id, author_id
) t
ON task_id = tId AND author_id = aId AND last_update = lastUp
Pour faire une sous-requête, vous devez utiliser subList_select.
Je ne pouvais pas trouver un moyen de le combiner avec le motif correspondant à:
from $ \(s `InnerJoin` ?subQueryhere?) -> do ...
Alors j'ai essayé avec where_
à la place:
where_ (s ^. ScenarioTaskId ==. (subList_select $
from $ \s' -> do
groupBy (s' ^. ScenarioTaskId, s' ^. ScenarioAuthorId)
return s'
) ^. ScenarioTaskId)
Cependant, cela ne compile pas depuis subList_select
renvoie expr (ValueList a)
au lieu d'un expr (Entity Scenario)
.