How can I get the top x% of values in a database table.
For example, I have a log file that I loaded into a db table. I would like to throw out the longest running 1% of requests as they skew the data.
Any simple way to do this?
BTW I am using derby database.
Thanks
Do you need accumulated or individual percent? I don’t know a way to calculate the accumulated total using Derby, but I know a way for the H2 database / MySQL. So only the first part of my example will work for Derby. For MySQL, you need to replace CAST(… AS INTEGER) with CAST(… AS SIGNED INTEGER):