How to perform ASC and DESC in subqueries

Hello, i want to know how can one perform order by ASC and DESC both in different subqueries. Influd doesn’t allow to do this. Is there any workaround for this ?

i have 3 subqueries one that select value before a certain timestamp, one that select values between timestamps and last that select value after certain timestamp

  1. for first subquery DESC is good because i want last value
  2. for third i want ASC because i want most recent value

Hello @kakarot007,
Thank you for your question. Can you please provide some more information? Maybe some dummy data or an example query that you’re trying? I’m having trouble understanding why you’re having trouble using ASC and DESC.

i want to use them in same query but influx gives an error.

ERR: subqueries must be ordered in the same direction as the query itself

and this is my query

 select * FROM (select * from Event  where time < '2019-07-04T09:43:00Z' group by "name" order by desc limit 1),(select * from Event where time > '2019-07-04T09:50:00Z' group by "name" order by asc limit 1), (select * from Event WHERE time >= '2019-07-04T09:43:00Z' AND time <= '2019-07-04T09:50:00Z' group by "name" order by desc limit 1) group by "name" order by desc