I have the following Table Documents
where data is stored in JSON format.
DocumentID Status Data
------------------------------------------
1 Active '{ "AccountNumber":["A1","A2","A3","A4"] }'
2 Active '{ "AccountNumber":["A1","A3"] }'
3 Active '{ "AccountNumber":["A2","A4"] }'
4 Active '{ "AccountNumber":["A1"] }'
Then i have filter which is also a json
DECLARE @filter = '{ "AccountNumber":["A2","A3"] }'
How do i apply filter in where clause.
The expected result should return matching Documents, DocumentID 1,2,3
SELECT DocumentID
FROM Documents D
WHERE
JSON_QUERY(D.Data,'$.AccountNumber') IN JSON_QUERY($(@filter,'$.AccountNumber') -- This is not working