<div dir="ltr"><div>Hi,</div><div><br></div><div>I am using beam library in my project and trying to express a query with a several aggregating subqueries:</div><div><br></div><div><pre class="gmail-notranslate" style="margin-left:40px"><code class="gmail-notranslate">select
(select * from t order by ts desc limit 1),
(select * from t order by ts asc limit 1),
</code><code class="gmail-notranslate"> (select count(*) from t) as nnn</code></pre> I figured out how to do multiple columns:</div><div style="margin-left:40px">userDataTableDigestQ :: UserTable -> SqlSelect<br> Postgres (UserDataTable, UserDataTable)<br>userDataTableDigestQ ut = select ag<br> where<br> al = all_ (userDataTableRef $ usertableName ut)<br> ag = subselect_ $ aggregate_<br> (BF.bimap group_ group_)<br> ((,)<br> <$> limit_ 1 (orderBy_ (asc_ . userdatatableTs) al)<br> <*> limit_ 1 (orderBy_ (desc_ . userdatatableTs) al))</div><div><br></div><div>but mixing group_ and count_ produces a very long type error<br></div><div><br></div><div>Is there other sql-backend agnostic Haskell library which could express the query above?<br></div><div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><br>Best regards,<br>Daniil Iaitskov<br> <br><br><br></div></div></div>