I am stuck with an issue with InfluxDB.
I would like to show a value with its derivative.
If I try the following:
SELECT DERIVATIVE(value) FROM (SELECT value FROM MyValues WHERE "f"='myfield')
...I get the derivative values. If I try the following:
SELECT value, DERIVATIVE(value) FROM (SELECT value FROM MyValues WHERE "f"='myfield')
...I get an empty result. So apparently I cannot mix the derivative with the normal values?!
Thanks for any help!
Derivative returns the rate of change for the values in a single field in a series.
InfluxDB calculates the difference between chronological field values and converts those results into the rate of change per unit.
SELECT DERIVATIVE(<field_key>, [<unit>]) FROM <measurement_name> [WHERE <stuff>]
When you select the aggregate function then you can't select ValueField seperatly.
Influxdb Derivative Reference
Thanks for the reply.
At the end I managed to get what I wanted with quite a complicated query:
SELECT value FROM
(SELECT MEAN(V) AS value, MEAN(D) AS Derivative FROM
(SELECT DERIVATIVE("value") as D FROM "MyValues" WHERE "f"='myfield' ),
(SELECT "value" as V FROM "MyValues" WHERE "f"='myfield')
GROUP BY time(1m) fill(none)
) WHERE Derivative!=0
Related
I have the following query:
SELECT sum("field1" * "field2") FROM "my_db"."autogen"."data" GROUP BY time(1d) FILL(null)
In short I would like to perform the operation sum on the product of two fields field and field2.
The above query returns an error: expected field argument in sum().
Is this kind of thing at all possible in InfluxDB?
Here's a idea: try Sub Query
Note:I don't have editor right now so it might give error too
SELECT SUM(Multiplication) FROM
(SELECT "field1" * "field2" as Multiplication, time(1d) as Days FROM
"my_db"."autogen"."data" GROUP BY time(1d) FILL(null)
) GROUP BY Days
I have a atble in InfluxDB, which has some values. So what I wanted to do is that I wanted to calculate the difference changing with values. Here is my query:
SELECT * FROM (SELECT DIFFERENCE(value) FROM table) WHERE difference = 1;
And I wanted to select all values from the table, where detected difference is 1 an then since DIFFERENCE() function returns second value of difference between two values from the table I wanted to get this second value from the table, because I want to create a function for an anomaly that is detected between measurements A and B, where time(a) < time(b) and this function should return B.
Has anyone have an idea how can I do that with a single InfluxDB query?
In SPSS Statistics Syntax File, I am looking to create a variable that calculates rank based on a desired partitioned column (e.g. equivalent to SQL "rank over (partition by column_a order by column b)" in Oracle SQL developer).
Please see the example:
Initial data without any filters:
Final output after applying get_rank:
To create a rank variable as described, first sort your data and then use the LAG function.
SORT CASES BY column_a column_b .
compute rank=1 .
IF ($CASENUM>1 AND column_a=LAG(column_a)) rank=LAG(rank) + 1 .
EXE .
LAG will look at the value of column_a for the prior case. In the syntax above it checks whether the value in column_a is different from that of the prior case.
If it has, then it will set the rank to 1. If it hasn't, then it will add 1 to the rank of the prior case. Just make sure your data is properly sorted first.
From there, if you want to look only at records that are rank=1, you can either use FILTER BY or SELECT IF to do that.
If indeed you only need the key to filter for key=1 then you can use this:
SORT CASES BY column_a column_b .
match files /file=* /by column_a /first=key1.
Now variable key1 will have value 1 for every first occurence of a column_a category, and you can use it to filter or select.
For a full ranking variable you can use this (don't even need to sort first):
RANK VARIABLES=b (A) BY a /RANK /TIES=MEAN.
I am a newbie to influxdb. I just started to read the influx documentation.
I cant seem to get the equivalent of 'select count(*) from table' to work in influx db.
I have a measurement called cart:
time status cartid
1456116106077429261 0 A
1456116106090573178 0 B
1456116106095765618 0 C
1456116106101532429 0 D
but when I try to do
select count(cartid) from cart
I get the error
ERR: statement must have at least one field in select clause
I suppose cartId is a tag rather than a field value? count() currently can't be used on tag and time columns. So if your status is a non-tag column (a field), do the count on that.
EDIT:
Reference
This works as long as no field or tag exists with the name count:
SELECT SUM(count) FROM (SELECT *,count::INTEGER FROM MyMeasurement GROUP BY count FILL(1))
If it does use some other name for the count field. This works by first selecting all entries including an unpopulated field (count) then groups by the unpopulated field which does nothing but allows us to use the fill operator to assign 1 to each entry for count. Then we select the sum of the count fields in a super query. The result should look like this:
name: MyMeasurement
----------------
time sum
0 47799
It's a bit hacky but it's the only way to guarantee a count of all entries when no field exists that is always present in all entries.
Using SSRS, If I've created a data set using code (I've got the following union statement). What I would like to do is to say - only return the data of the one - where the parameter passed (is customer_no) basically where a.customer_no = customer_no that is passed as a parameter. But I don't think I'm doing this accurately.
select reservation_no,
customer_no,
'GT Adult' as 'price_type',
a.adult as pt,
(select b.adult from LT_CHC_TOURS_RSV_PRICE b) as current_price
FROM LV_CHC_TOURS_RSV_DATA a
WHERE a.customer_no = Fields!customer_no.Value
union
select reservation_no,
customer_no,
'GT Senior/Student' as 'price_type',
a.senior_student,
(select b.senior_student from LT_CHC_TOURS_RSV_PRICE b) as current_price
from LV_CHC_TOURS_RSV_DATA a
WHERE a.customer_no = Fields!customer_no.Value
What do I replace Fields! customer_no.Value with?
In your Dataset query, change Fields!customer_no.Value to #SomeParameterName.
Then, still in the dataset, go to the parameters tab, and map the dataset parameter to your report parameter.