diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,5 +1,8 @@
 # Changelog for pg-schema
 
+## 0.7.1.2
+- Fix bug with aggregates (Min/Max/Sum/Avg)
+
 ## 0.7.1.1
 - Add upsertJSONText, upsertJSONText_
 
diff --git a/pg-schema.cabal b/pg-schema.cabal
--- a/pg-schema.cabal
+++ b/pg-schema.cabal
@@ -1,6 +1,6 @@
 cabal-version:  3.12
 name:           pg-schema
-version:        0.7.1.1
+version:        0.7.1.2
 category:       Database
 author:         Dmitry Olshansky
 maintainer:     olshanskydr@gmail.com
diff --git a/src/PgSchema/Ann.hs b/src/PgSchema/Ann.hs
--- a/src/PgSchema/Ann.hs
+++ b/src/PgSchema/Ann.hs
@@ -165,6 +165,10 @@
         (ApplyRenamer ren fld) ('RFToHere fromTab refs) ]
     ColFI ann fld ('RFSelfRef tab refs) [t] = ColFI ann fld ('RFToHere tab refs) [t]
     ColFI ann fld ('RFSelfRef tab refs) t = ColFI ann fld ('RFFromHere tab refs) t
+    ColFI ('Ann ren sch d tab) fld ('RFPlain fd) (Aggr af t) =
+      '[ 'ColInfo '(fld, 0) (Aggr af t) (ApplyRenamer ren fld) ('RFAggr fd af 'True) ]
+    ColFI ('Ann ren sch d tab) fld ('RFPlain fd) (Aggr' af t) =
+      '[ 'ColInfo '(fld, 0) (Aggr' af t) (ApplyRenamer ren fld) ('RFAggr fd af 'False) ]
     ColFI ('Ann ren sch d _) fld fd t = '[ 'ColInfo '(fld, 0) t (ApplyRenamer ren fld) fd ]
 --------------------------------------------------------------------------------
 -- GCols (closed TF: Generic Rep)
diff --git a/test-pgs/Main.hs b/test-pgs/Main.hs
--- a/test-pgs/Main.hs
+++ b/test-pgs/Main.hs
@@ -13,6 +13,7 @@
 import Tests.InsertJSONTransaction
 import Tests.UpsertUniqueKey
 import Tests.Conditions
+import Tests.Aggregates
 
 prop_not_implemented :: Property
 prop_not_implemented = property $ fail "not implemented"
@@ -60,6 +61,10 @@
     , testGroup "Query (test_dml)"
       [ testProperty "'Simple' queries" $ prop_cond_query pool
       , testProperty "Conditions by duplicated path" $ prop_cond_by_dup_path pool
+      ]
+    , testGroup "Aggregates (test_dml)"
+      [ testProperty "Aggr' on plain column is not in GROUP BY" $
+          prop_selectText_aggr_plain_not_in_group_by pool
       ]
     --   , testProperty "Cond: Child / Parent exists" prop_not_implemented
     --   , testProperty "Conditions by path (root vs nested path)" prop_not_implemented
diff --git a/test-pgs/Tests/Aggregates.hs b/test-pgs/Tests/Aggregates.hs
--- a/test-pgs/Tests/Aggregates.hs
+++ b/test-pgs/Tests/Aggregates.hs
@@ -1,11 +1,27 @@
+{-# LANGUAGE BlockArguments #-}
 module Tests.Aggregates where
 
 import Data.Pool as Pool
-import Database.PostgreSQL.Simple
+import Data.Text as T
+import Database.PostgreSQL.Simple (Connection)
+import GHC.Int
 import Hedgehog
+import PgSchema.DML
+import Utils
 
-prop_aggr_multiple_max_min :: Pool Connection -> Property
-prop_aggr_multiple_max_min _pool = property success
 
-prop_aggr_duplicate_names_nested :: Pool Connection -> Property
-prop_aggr_duplicate_names_nested _pool = property success
+type RootGroupSel =
+  "grp" := Int32
+  :. "cnt" := Aggr' ACount Int64
+  :. "name" := Aggr' AMin Text
+
+
+-- | 'Aggr'' on a plain column must become SQL aggregate, not GROUP BY key.
+prop_selectText_aggr_plain_not_in_group_by :: Pool Connection -> Property
+prop_selectText_aggr_plain_not_in_group_by _pool =
+  property do
+    let (sql, _) = selectText (AnnSch "root") @RootGroupSel qpEmpty
+    T.isInfixOf "count(*)" sql === True
+    T.isInfixOf "min(t0.name)" sql === True
+    T.isInfixOf "group by grp" sql === True
+    T.isInfixOf ",name" sql === False
