I have a presto view from where I need to create nested JSON. I have tried with the below query:
SELECT CAST(CAST(ROW('Sales (PTD)' as Ttl,unsale as Val) AS ROW(v1 VARCHAR, v2 VARCHAR)) AS JSON)
from metrics_v where time_frame='PTD';
I need a JSON result like below:
"SlsPTD": {
"Ttl": "Sales (PTD)",
"Val": "103.27290344238281"
}
But it is currently throwing error: SQL Error [1]: Query failed (#20220725_063102_03638_j2tav): line 1:36: mismatched input 'as'. Expecting: ')', ','
How to get the expected result?