Jump to content
Server Maintenance This Week. ×

Validate non zero or null value in ExecuteSQL before division


This topic is 1103 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi guys,

I'm scratching my head trying to use ExecuteSQL syntax. How can I prevent a division if a value is null or zero in a SELECT statement?

Here's a simplified version of my query.

"SELECT exp.labels, SUM (exp.budgeted) as budget" & ", SUM (exp.expenditure) as expense,";
"IF (expense > 0) SELECT (budget / expense) ELSE NULL"; // <--- THIS IS WHAT I WANT TO FIX
"FROM expenditures AS exp";
"WHERE exp.id IN (" & ids & ")";
"GROUP BY exp.labels"

Thanks

Edited by El_Pablo
Link to comment
Share on other sites

This topic is 1103 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.