Pregunta

Kdb calculates infinity for null column if group by is performed.

t:([]a: 1 1 2;b: 3 2 0n)
select min b by a from t

a       
1   2.0
2   ow

ow is infinity.

Is there any way I can get null(0n) for 2

¿Fue útil?

Solución 2

That's the expected result; you need to update afterwards:

update b:?[0w=b;0N;b] from select min b by a from t

Otros consejos

From Jeff Borror's q for mortals:

q)min 0N 5 0N 1 3                  / nulls are ignored
1
q)min 0N 0N                        / infinity if all null
0W

http://code.kx.com/q/ref/stats-aggregates/#min-minimum

You should be careful when operating with nulls. Note the following

as additional info:

q)max 0N 0N
-0W
q)min 0N 0N
0W
q)0N+2
0N
q)sum 0N 2
2
q)sum 0N 0N
0
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top