differ by in qsql

https://learninghub.kx.com/forums/topic/differ-by-in-qsql

can I have an example of using differ in a qsql please!
I want to only output rows where the rows in the table differ on one column but by each sym?

Hi,

I believe this is what you are looking for.

q)t:([] sym:`a`a`a`b`b`c`c`a`b`c;price:1 1 2 3 4 5 5 8 9 7)

q)t

sym price

---------
a 1
a 1
a 2
b 3
b 4
c 5
c 5
a 8
b 9
c 7

q)select from t where (differ;price) fby sym

sym price

---------
a 1
a 2
b 3
b 4
c 5
a 8
b 9
c 7

 

You can read more about fby here fby – Reference – kdb+ and q documentation - kdb+ and q documentation (kx.com)

Hi @kdb_newbie

I have reformatted this question due to issues with our editor.

Thank you @unterrainer_ale for providing an example.

Thanks,

Megan