I'm trying to create a Cosmo DB stored procedure to return the results of a relatively simple SQL statement. If it were purely SQL I would be fine but since I know nothing about JavaScript I'm struggling mightily. Any help would be very much appreciated. Here is the SQL query:
SELECT distinct cx.ID, cxa.FieldValue as PartNo, cx.TransactionDate, cx.TransactionStatus
FROM c
JOIN cx in c.File.Transactions
JOIN cxa in cx.AppDetails
JOIN
(
SELECT cx2.ID, cxa2.FieldValue as PartNo, max(cx2.TransactionDate) as TransactionDate
FROM c
JOIN cx2 in c.File.Transactions
JOIN cxa2 in cx2.AppDetails
WHERE c.File.Category= 'BatchParts' and cxa2.FieldName ='PartNo'
GROUP BY cx2.ID,cxa2.FieldValue
) B
WHERE c.File.Category= 'BatchParts' and cxa.FieldName ='PartNo'