79576795

Date: 2025-04-16 09:21:00
Score: 1.5
Natty:
Report link

Sample table (please provide this in future):

q)trade_usq:([] price:0n 99 98 97;size:1 2 0N 4;id:`a`b`a`b;ex:`c`c`d`d)
q)trade_usq
price size id ex
----------------
      1    a  c
99    2    b  c
98         a  d
97    4    b  d
q)select sum size by ticker:((string[id],'"."),'string[ex])from trade_usq where any not null(size;price)
ticker| size
------| ----
"a.c" | 1
"a.d" | 0
"b.c" | 2
"b.d" | 4

Using table can then confirm @s2ta answer provides the expected output:

q)w:enlist (any;(not;(null;(enlist;`size;`price))))
q)a:enlist[`size]!enlist(sum;`size)
// Key change: for ,' you need to keep , and not replace with enlist:
q)b:enlist[`ticker]!enlist ((';,);((';,);(string;`id);".");(string;`ex))
q)?[trade_usq;w;b;a]
ticker| size
------| ----
"a.c" | 1
"a.d" | 0
"b.c" | 2
"b.d" | 4
Reasons:
  • RegEx Blacklisted phrase (2.5): please provide
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @s2ta
  • High reputation (-1):
Posted by: rianoc