2018.06.19 03:19 AM
2018.06.20 07:08 AM
q)select from t where i=(first;i)fby ([]a;b)
a b c
-----
1 1 a
1 2 b
2018.06.20 07:22 AM
2018.06.20 08:04 AM
select by a,b from t
This will return last row for each a,b distinct combination.
Or if you want first entry, you can use:
select first c by a,b from t
This gives some performance improvement over fby but if you have fat table and require many columns into output then fby makes that job easy.
q)show t:([]a:1 1 1;b:1 2 2;c:`a`b`c)a b c-----1 1 a1 2 b1 2 ci can find distinct rows considering a,b byq)distinct select a,b from ta b---1 11 2but need to incorporate the c column so the result i want might bea b c------1 1 a1 2 bso an idistinct would be helpful à la iasc:q)t idistinct select a,b from ta b c------1 1 a1 2 bcan idistinct or other useful function be built with similar performance to distinct?thanks guys.
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.