我有下面的 Json 字符串。我需要编写一个查询来获取 SP 记录。在不提供索引值的情况下,我们需要得到结果。
{
"S": [
{
"Name": "Project1",
"SP": [
{
"ID": 1,
"Name": "Test1"
},
{
"ID": 2,
"Name": "Test2"
},
}]}
如何查询以获取 SP 值。
Expected Result:
ID Name
1 Test1
2 Test2
I tried the below but not working. Can you please suggest the correct query.
SELECT DISTINCT JSON_VALUE(JsonData, '$.S[0].SP.ID') AS ID,
JSON_VALUE(JsonData, '$.S[0].SP.Name') AS Name
FROM TableA