How to convert influxdb query to Kapacitor TICK script?

Hi,

how can i convert influxdb query to Kapacitor TICK script in a batch node.
In terminal when i queried the below command
SELECT min(usage_user) FROM "telegraf"."autogen"."cpu" WHERE cpu = 'cpu-total' AND time > now()-7d

name: cpu
time                min
----                ---
1548634875000000000 0.1752190237792004

But in TICK script

var weeklyMinimum = batch
    |query('''SELECT mean(usage_user) AS usage_user FROM "telegraf"."autogen"."cpu"  WHERE cpu = 'cpu-total' ''')
        .period(7d)
        .every(30s)
    |httpOut('step3')

{"series":[{"name":"cpu","columns":["time","usage_user"],"values":[["2019-01-25T21:31:10.036028537Z",4.105535864528607]]}]}

Which is completely different from the influxdb query ?

Thanks

Hi @BhanuKiran

One query is using min and one is using mean

HI Sorry,
I just checked this mistake.

No problem, happy to be the rubber duck!