I have a query that returns a stats table with all the data I care about, but there's a calculation I'd like to add to this presentation, and I can't seem to figure out how to get it. My stats table looks like this:
group num
---- ----
a 10
20
------------
b 10
20
------------
c 20
35
5
7
------------
d 8
16
I'd like to get the difference of the num field between each pair of rows so I don't have to calculate it manually, while still having the full context of each line. So I want something that looks like this:
group num diff
---- ---- ----
a 10
20 10
--------------------
b 10
20 10
--------------------
c 20
35 15
5
7 2
--------------------
d 8
16 8
I thought I could just pipe everything through the delta command on the num field, even if instead of empty values where I want for the diff field it naively diffed the row above, but that didn't work. Do I need to transform the stats table into a regular table with the 'group' values repeating, or is it something else?
... View more