dotq - kdb+: group by and sum over multiple columns -


consider following data:

table:  time          cola    colb     colc ----------------------------------- 11:30:04.194  31      250      11:30:04.441  31      280      11:30:14.761  31.6    100      11:30:21.324  34      100      11:30:38.991  32      100      b 11:31:20.968  32      100      b 11:31:56.922  32.2    1000     b 11:31:57.035  32.6    5000     c 11:32:05.810  33      100      c 11:32:05.810  33      100      11:32:14.461  32      300      b 

now how can sum colb whenever colc same, without losing time order.

so output be:

first time    avga    sumb     colc ----------------------------------- 11:30:04.194  31.2    730      11:30:38.991  32.07   1200     b 11:31:57.035  32.8    5100     c 11:32:05.810  33      100      11:32:14.461  32      300      b 

what have far:

select time (select first time, avg cola, sum colb colc, time table) 

but output not grouped colc. how should query like?

how this?

get select first time, avg cola, sum colb, first colc sums colc<>prev colc table 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -