Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate minimum and maximum values of each variable in a table in kdb

Tags:

q-lang

kdb+

Consider the following table:

sym A B
X   1 2
Y   4 1
X   6 9
Z   6 3
Z   3 7
Y   1 8

I want to find the minimum A value and maximum B value for each of my symbols X, Y & Z and display them in a new table, i.e.

sym minA maxB
X   1    9
Y   1    8
Z   3    7

Thanks.

like image 912
Jonathan Avatar asked Dec 09 '25 10:12

Jonathan


1 Answers

This should do it;

  select minA:min A, maxB:max B by sym from table
like image 65
Chromozorz Avatar answered Dec 11 '25 17:12

Chromozorz