I've added the having method to support HAVING clause with some aggregate functions like this:
ret <- select $
from $ \(p `LeftOuterJoin` b) -> do
on (p ^. PersonId ==. b ^. BlogPostAuthorId)
let cnt = count (b ^. BlogPostId)
groupBy (p ^. PersonId)
having (cnt >. (val 0))
orderBy [ asc cnt ]
return (p, cnt)
It generates
SELECT "Person"."id", "Person"."name", "Person"."age", COUNT("BlogPost"."id")
FROM "Person" LEFT OUTER JOIN "BlogPost" ON "Person"."id" = "BlogPost"."authorId"
GROUP BY "Person"."id"
HAVING COUNT("BlogPost"."id") > ?
ORDER BY COUNT("BlogPost"."id") ASC
I've added the
having
method to supportHAVING
clause with some aggregate functions like this:It generates