1

Consider the following data:

table:

time          colA    colB     colC
-----------------------------------
11:30:04.194  31      250      a
11:30:04.441  31      280      a
11:30:14.761  31.6    100      a
11:30:21.324  34      100      a
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      a
11:32:14.461  32      300      b

Now how can I sum colB whenever colC is the same, without losing the time order.

So the output would be:

first time    avgA    sumB     colC
-----------------------------------
11:30:04.194  31.2    730      a
11:30:38.991  32.07   1200     b
11:31:57.035  32.8    5100     c
11:32:05.810  33      100      a
11:32:14.461  32      300      b

What I have so far:

select by time from (select first time, avg colA, sum colB by colC, time from table)

But the output is not grouped by colC. How should the query look like?

2 Answers 2

4

How about this?

get select first time, avg colA, sum colB, first colC by sums colC<>prev colC from table
Sign up to request clarification or add additional context in comments.

Comments

1

A slightly different way to achieve this using differ :

value select  first time, avg colA, sum colB , first colC by g:(sums differ colC) from table 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.