Skip to content

Commit c40f4e8

Browse files
authored
Update README.md
1 parent b9211db commit c40f4e8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
# mysql-percentile
2-
user-defined function to calculate percentiles in a MySQL query
2+
user-defined aggregate function to calculate percentiles in a MySQL query, similar to min/max/avg.
3+
4+
Compile with:
5+
gcc -fPIC -Wall -I /usr/include/mysql51/mysql/ -shared -o udf_percentile.so udf_percentile.cc
6+
7+
Copy to the plugin directory of MySQL (SHOW VARIABLES LIKE 'plugin_dir')
8+
cp udf_percentile.so /usr/lib64/mysql/plugin
9+
10+
Register the function:
11+
CREATE AGGREGATE FUNCTION percentile RETURNS REAL SONAME 'udf_percentile.so'
12+
13+
Use the function:
14+
SELECT percentile(loadTime, 99) FROM user_data GROUP BY WEEK(`timestamp`)

0 commit comments

Comments
 (0)