Using 'Aggregate' result as sub query.
Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com

Using 'Aggregate' result as sub query.

Use case: You have a form that allows multiple data entries, and you want to retrieve the latest entry. To achieve this, you thought of building a query that uses the 'Max' aggregate function, then use it as a sub-query.

Currently, this is not supported.

You can use the 'Identifier' or 'Datetime' field (if added) for a form and apply the 'Max' aggregate function in the query to export the aggregated result.
Copy the identifiers from the CSV file and create another query using the 'Is One Of' operator to achieve your usecase.

Expand to see the steps in detail:

  1. Create a query to get the 'Max' results --> Export the results.

    image-20250829-142754.png
    image-20250829-142653.png
  2. Open CSV file and copy the identifiers.

Pro tip: If you are using a spreadsheet program, place your cursor to first identifer and can use the shortcut Ctrl/CMD + Shift + Down Arrow to select all identifiers and press Ctrl/CMD + C to copy the values.

  1. Create a new query in OpenSpecimen, add a filter on the form identifer as ‘Is One Of’ and paste the values.

    image-20250829-143021.png

OpenSpecimen consider the values as seprate, if the values have comma, tab or newline present in between them.

  1. Add additional filter (if any) --> Click on ‘View Records’ --> Select the required columns, to see the desired results.

 

 

Got feedback or spotted a mistake?

Leave a comment at the end of this page or email contact@krishagni.com