diff --git a/Eloquent/Concerns/QueriesRelationships.php b/Eloquent/Concerns/QueriesRelationships.php
index <HASH>..<HASH> 100644
--- a/Eloquent/Concerns/QueriesRelationships.php
+++ b/Eloquent/Concerns/QueriesRelationships.php
@@ -414,7 +414,10 @@ trait QueriesRelationships
                 preg_replace('/[^[:alnum:][:space:]_]/u', '', "$name $function $column")
             );
 
-            $this->selectSub($query->limit(1), $alias);
+            $this->selectSub(
+                $function ? $query : $query->limit(1),
+                $alias
+            );
         }
 
         return $this;
Fix withAggregate issue caused by limit 1 for aggregation functions (#<I>)