I have following query:
SELECT s."Description",
sp.*
FROM "Supplier" as s
OUTER APPLY (
SELECT p."Id", p."Description", p."Price"
FROM "Products" as p
WHERE p."SupplierId" = s."Id"
FOR JSON auto
) as sp
I'm trying to build json array according to OUTER APPLY
result but I stuck here because there is an error No column name was specified for column 1 of 'sp'.
I found similar question here on stackoverflow, but there is no example with outer apply.
Can you explain me what is wrong with this query?
1条答案
按热度按时间qyswt5oh1#
You just need to add a column alias to your applied result
sp
, e.g.sp(json)
:You can then access this in your overall results as either
sp.*
orsp.json
, since the column is now named.