2019.05.16 07:48 PM
2019.05.17 01:42 AM
2019.05.21 12:50 AM
signum is likely the operator you are looking for this test. will result in -1, 0 or 1 for your testnot sure if you want running days, or just count days, but below is a count example
q)n:100; t:([]date:n?.z.d;sym:n?`1;pct:
(n?100)*n?-1 0 1)
q)select count date by sym, signum pct from t
sym pct| date
-------| ----
a -1 | 1
a 0 | 6
a 1 | 1
b -1 | 1
b 0 | 4
b 1 | 4
...// alternative layout with exec
q)exec count@'`less`zero`more!(group signum pct)[-1 0 1] by sym from t
| less zero more
-| --------------
a| 1 6 1
b| 1 4 4
c| 1 0 2
d| 2 0 5
...HTH,
Sean
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.