You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a feature request for a new function in Influx. I'd like you to add an if statement into a select clause. For example, I'd like to be able to do something along the following lines:
select sum(if(key = 'a', value, 0)) as a_value,sum(if(key = 'b', value, 0)) as b_value,time from measure where key = 'a' or key = 'b' group by time(1h);
At the moment the only way I can get results back as individual columns matching multiple keys is to merge the data by the same time [from multiple selects] on the server which will be time-consuming and resource hungry, particularly for large datasets. An if statement would give me the ability to calculate the values directly in the query. Ideally, the if statement would allow me to go multiple levels deep too, e.g.
select sum(if(key = 'a', if (source = 'x', value, 0), 0)) as value...
Is this something that you can consider for a future release? Alternatively, a case statement would be just as useful, as per SQL.
Thanks a lot.
Regards,
Marcus.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had recent activity. Please reopen if this issue is still important to you. Thank you for your contributions.
Hi there,
I have a feature request for a new function in Influx. I'd like you to add an if statement into a select clause. For example, I'd like to be able to do something along the following lines:
select sum(if(key = 'a', value, 0)) as a_value,sum(if(key = 'b', value, 0)) as b_value,time from measure where key = 'a' or key = 'b' group by time(1h);
At the moment the only way I can get results back as individual columns matching multiple keys is to merge the data by the same time [from multiple selects] on the server which will be time-consuming and resource hungry, particularly for large datasets. An if statement would give me the ability to calculate the values directly in the query. Ideally, the if statement would allow me to go multiple levels deep too, e.g.
select sum(if(key = 'a', if (source = 'x', value, 0), 0)) as value...
Is this something that you can consider for a future release? Alternatively, a case statement would be just as useful, as per SQL.
Thanks a lot.
Regards,
Marcus.
The text was updated successfully, but these errors were encountered: