1
select 
    (`Setup` + `run` + `cleanup`) / `QNTY`
from 
    the_table 
where 
    date_field >= "2012-01-01" and
    Num = 4;

Every time I execute this query in MySQL workbench, the workbench application crashes immediately. Looks like something that I have done many times before, not sure what the problem is.

Only thing I can think of is a problem with null values. Sometimes (Setup + run + cleanup) will return a null, and sometimes QNTY is null also.

I just checked, and this query also causes a crash:

select 
    (`Setup` + `run` + `cleanup`) / `QNTY`
from 
    the_table
where 
    date_field >= "2012-01-01" and
    (`Setup` + `run` + `cleanup`) is not null and
    `QNTY` is not null and
    `QNTY` != 0 and
    Num = 4

Thanks.

6
  • yeah i just checked, it still crashes Commented Jun 8, 2012 at 15:14
  • 1
    I quickly tested this via a PHP MyAdmin interface. The math worked fine. I tried a null in the addition part and a null in the division part and the result was just null. Maybe it is a Workbench bug? Commented Jun 8, 2012 at 15:17
  • Maybe you should check this out; dev.mysql.com/doc/refman/5.5/en/… Commented Jun 8, 2012 at 15:17
  • start the workbench from terminal and see the logs when it crashes. it may give some hints. Commented Jun 8, 2012 at 15:17
  • If QNTY is very, very small, the result would be very, very large. What the smallest value for QNTY? btw, if QNTY is an int, forget this as a reason Commented Jun 8, 2012 at 15:21

2 Answers 2

1

I would try

select 
    (coalesce(Setup, 0) + coalesce(run, 0) + coalesce(cleanup, 0)) / QNTY
from 
    the_table
where 
    date_field >= '2012-01-01' and
    Num = 4 and
    coalesce(QNTY, 0) <>0
Sign up to request clarification or add additional context in comments.

1 Comment

Still crashed using this syntax, it must be a bug in Workbench
0

Looks like a bug in workbench as suggested by Darkwater23 in the comments. I tried on the old MySQL Query Browser and it executed fine with nulls and zeros and everything.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.