I have a series of documents in the bucket in which I will like to group by by fields, kvp.internal and kvp.external and return only the document with highest value in metadata.published among the grouped fields.
You can assume that published is always unique and incremental.
E.g. I would like to retrieve the following results from the bucket as described below.
If I were to keep it as 1, it returns no result where changing it to 0 returns the max value of published. I guess the square bracket refers to the index in the array where max is evaluated. Clearly I can be wrong here as I am quite new to n1ql.
SELECT MAX( [metadata.published, doc])[1] AS d
FROM zeusresource
GROUP BY kvp.internal, kvp.external;
Hi,
I have Sample bucket, with multiple documents having an attribute lineaItemID. Its values are integer ( like 1,2,3,4,…).
Now, want to take maximum lineItmeID from this bucket using below query: select max(u.lineItemID ) from Sample u where meta(u).id like “For Profit:%”;
But, the result is not coming properly. Could you please let me know whether the query is correct or not. If not , the please share the query.
To help debug the problem, could you give us some sample data (maybe 5 simplified documents) that shows the problem? Also, what version are you running?