From b8220c084ddda0a848bdce5c8d82a0d4d13b0de6 Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Wed, 25 Mar 2026 15:27:50 -0600 Subject: [PATCH] Update JSON object aggregation examples in documentation Results were included in the wrong place --- .../functions/json-objectagg-transact-sql.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/t-sql/functions/json-objectagg-transact-sql.md b/docs/t-sql/functions/json-objectagg-transact-sql.md index 44e3a3b7d4b..0c66c08ef45 100644 --- a/docs/t-sql/functions/json-objectagg-transact-sql.md +++ b/docs/t-sql/functions/json-objectagg-transact-sql.md @@ -106,6 +106,16 @@ FROM sys.columns AS c GROUP BY c.object_id; ``` +[!INCLUDE [ssresult-md](../../includes/ssresult-md.md)] + +| object_id | column_list | +| --- | --- | +| 3 | `{"bitpos":12,"cid":6,"colguid":13,"hbcolid":3,"maxinrowlen":8,"nullbit":11,"offset":10,"ordkey":7,"ordlock":14,"rcmodified":4,"rscolid":2,"rsid":1,"status":9,"ti":5}` | +| 5 | `{"cmprlevel":9,"fgidfs":7,"fillfact":10,"idmajor":3,"idminor":4,"lockres":17,"maxint":13,"maxleaf":12,"maxnullbit":11,"minint":15,"minleaf":14,"numpart":5,"ownertype":2,"rcrows":8,"rowsetid":1,"rsguid":16,"scope_id":18,"status":6}` | +| 6 | `{"cloneid":6,"dbfragid":8,"id":1,"partid":3,"rowsetid":7,"segid":5,"status":9,"subid":2,"version":4}` | +| 7 | `{"auid":1,"fgid":5,"ownerid":3,"pcdata":10,"pcreserved":11,"pcused":9,"pgfirst":6,"pgfirstiam":8,"pgroot":7,"status":4,"type":2}` | +| 8 | `{"fileid":2,"filename":4,"name":3,"status":1}` | + ### D. Return a JSON object as JSON type The following example returns a JSON object as **json** type. @@ -120,16 +130,6 @@ SELECT JSON_OBJECTAGG('a':1 RETURNING JSON); {"a":1} ``` -[!INCLUDE [ssresult-md](../../includes/ssresult-md.md)] - -| object_id | column_list | -| --- | --- | -| 3 | `{"bitpos":12,"cid":6,"colguid":13,"hbcolid":3,"maxinrowlen":8,"nullbit":11,"offset":10,"ordkey":7,"ordlock":14,"rcmodified":4,"rscolid":2,"rsid":1,"status":9,"ti":5}` | -| 5 | `{"cmprlevel":9,"fgidfs":7,"fillfact":10,"idmajor":3,"idminor":4,"lockres":17,"maxint":13,"maxleaf":12,"maxnullbit":11,"minint":15,"minleaf":14,"numpart":5,"ownertype":2,"rcrows":8,"rowsetid":1,"rsguid":16,"scope_id":18,"status":6}` | -| 6 | `{"cloneid":6,"dbfragid":8,"id":1,"partid":3,"rowsetid":7,"segid":5,"status":9,"subid":2,"version":4}` | -| 7 | `{"auid":1,"fgid":5,"ownerid":3,"pcdata":10,"pcreserved":11,"pcused":9,"pgfirst":6,"pgfirstiam":8,"pgroot":7,"status":4,"type":2}` | -| 8 | `{"fileid":2,"filename":4,"name":3,"status":1}` | - ### E. Return aggregated result with four columns The following example returns a result with four columns from a `SELECT` statement containing `SUM` and `JSON_OBJECTAGG` aggregates with `GROUP BY GROUPING SETS`. The first two columns return the `id` and `type` column value. The third column `total_amount` returns the value of `SUM` aggregate on the `amount` column. The fourth column `json_total_name_amount` returns the value of `JSON_OBJECTAGG` aggregate on the `name` and `amount` columns.