$db->select( [ "this", "that", "theother", "COUNT(*) as things" ], join( ' ', "foo", "LEFT JOIN bar USING( id )", ), [ "? <= stamp", "stamp < ?", @exclude ? "this NOT IN ( ?? )" : (), ], "GROUP BY this, that, theother", "ORDER BY that, this", "LIMIT $size OFFSET $skip", "HAVING 1 < count(*)", );