I have a table with following fields Id RequestId CategoryId 1 112 1 2 123 1 3 123 2SELECT R.RequestId, (SELECT RC.CategoryId FROM Request RC WHERE RC.Id = R.Id FOR JSON AUTO) AS CategoriesFROM Request RAbove query returns the data as mentioned below RequestId Categories 112 [{"CategoryId":"1"}] 123 [{"CategoryId":"1"},{"CategoryId":"2"}]But, I want that column name CategoryId should not be repeated for every item in json array. Thus, my expected result is: RequestId Categories 112 ["1"] 123 ["1","2"] 解决方案 Was used: SQL to JSON - array of objects to array of values in SQL 2016db<>fiddle here 这篇关于SQL查询以获取JSON结果中没有列名的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!