0

It seems we can not get distinct values from a keyed table in the same way as for unkeyed:

t:([a:1 2]b:3 4)
?[t;();0b;()]   // keyed table
?[0!t;();1b;()] // unkeyed table
?[t;();1b;()]   // err 'type

Why do we have this error here?

egor7
  • 4,678
  • 7
  • 31
  • 55

1 Answers1

2

I suspect it's the same reason you can't run distinct on a dictionary - it's ambiguous. Do you intend to apply distinct to the keys or the values? I think kdb doesn't pick a side so it makes you do it yourself.

q)t:([]a:1 1 1 2 2;b:10 12 10 14 14)
q)select distinct from t
a b
----
1 10
1 12
2 14
q)select distinct from 1!t
'type

q)distinct `a`b`c!(1;"ab";enlist 1b)
'type
terrylynch
  • 11,844
  • 13
  • 21