Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

KDB Select average of List data type for each row

Is there anyway in KDB to get the average of each row which has list data type ?
E.g. I have table with column ID and Size :

| ID | size      |
|----|-----------|
| 1  | [1,3]     |
| 2  | [3,3,3]   |
| 3  | [4,2,4,2] |

In select , I want ID and avg of size :

| ID | avg |
|----|-----|
| 1  | 2   |
| 2  | 3   |
| 3  | 3   |

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

q)t:([]id:1 2 3;size:(1 3;3 3 3;4 2 4 2))
q)t
id size
----------
1  1 3
2  3 3 3
3  4 2 4 2
q)select id,avg each size from t
id size
-------
1  2
2  3
3  3
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading