title: InfluxDB - query with aggregation function DIFFERENCE() that returns value from other query
body: <p>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:</p>
  
  <blockquote>
    <p>SELECT * FROM (SELECT DIFFERENCE(value) FROM table) WHERE difference = 1;</p>
  </blockquote>
  
  <p>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) &lt; time(b) and this function should return B.
  Has anyone have an idea how can I do that with a single InfluxDB query? </p>