I’m puzzled about how kdb performs grouped queries. When a query has no explicit results, but does have a grouping (e.g., “select by … from …”) kdb seems to implicitly return only the last element of each grouped column. When the result columns are specified explicitly, the values are lists as you’d expect. Why do implicit queries return only the last element?
It’s such a basic thing that there must be some reason (i.e., not a bug).
KDB+ 2.7 2011.06.13 Copyright (C) 1993-2011 Kx Systems
m32/ 2()core 4096MB andy mini.local 10.0.1.10 PLAY 2011.09.11
q)t:(x:1 0 1;y:2 3 4)
q)select by x from t
x| y
-| -
0| 3
1| 4
q)meta select by x from t
c| t f a
-| -----
x| i
y| i
Now, specify the result column explicitly:
q)select y by x from t
x| y
-| —
0| ,3
1| 2 4
q)meta select y by x from t
c| t f a
-| -----
x| i
y| I