Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: if statement #8627

Closed
moxie2207 opened this issue Jul 25, 2017 · 3 comments
Closed

Feature request: if statement #8627

moxie2207 opened this issue Jul 25, 2017 · 3 comments

Comments

@moxie2207
Copy link

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.

@snehabarshamishra
Copy link

snehabarshamishra commented Sep 27, 2018

#5383 -> Duplicate

@dgnorton dgnorton added the 1.x label Jan 7, 2019
@stale
Copy link

stale bot commented Jul 24, 2019

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.

@stale stale bot added the wontfix label Jul 24, 2019
@stale
Copy link

stale bot commented Jul 31, 2019

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.

@stale stale bot closed this as completed Jul 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants