Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Qt_script_any

Paweł Salawa edited this page Jan 15, 2018 · 1 revision

Definition

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.

Code

Initialization code:

n=0;
winner={};

Per step code:

n++;
if (Math.random()*n >= n-1)
 winner=arguments[0];

Final step code:

return winner;

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /