-
-
Notifications
You must be signed in to change notification settings - Fork 599
Qt_script_any
Paweł Salawa edited this page Jan 15, 2018
·
1 revision
Language: | Qt Script |
---|---|
Plugin for language: | ScriptingQt |
How to use: | Create custom SQL function, set it to "aggregate" type. Suggested name: any |
Function arguments | Keep undefined |
Function usage: | SELECT any(colName) from tableName |
Description: | Picks random value from set of values of an aggregated column. |
Initialization code:
n=0;
winner={};
Per step code:
n++;
if (Math.random()*n >= n-1)
winner=arguments[0];
Final step code:
return winner;