Querying for median value in LabKey?

LabKey Support Forum
Querying for median value in LabKey? olnerdybastid  2018-04-25 08:47
Status: Closed
 

I am writing a query to summarize some assay results with some very basic statistics (std dev, average, and median). The first two are already taken care of using standard LabKey SQL, but calculating median looks to be a bit more difficult unless I'm overlooking something

Our LabKey instance is deployed over Postgres, and I've seen multiple examples of how to do this natively in Postgres (one example here: https://www.periscopedata.com/blog/medians-in-sql). But I don't see anything analogous to to Postgres' ROW_NUMBER() in LabKey SQL, or any way to select an element by its position in a subselect. Is there a way to calculate median in a LabKey SQL query, or has anyone found an acceptable workaround to achieve this?

 
 
Jon (LabKey DevOps) responded:  2018-04-27 15:25
Hello,

There is a feature for Median, but it is within the UI and only with the Premium Editions of LabKey.

https://labkey.org/Documentation/wiki-page.view?name=aggregates

Regards,

Jon
 
olnerdybastid responded:  2018-05-01 03:32
Ah I see. Thanks for confirming.