some changes in workqueue to support smart retry handler

Currently the workqueue considers jobs in created, executing and the *failed and *cooloff states to determine whether to pull more work into WMBS. Change this to only look at created and executing jobs to allow the smart retry handler to function (it can leave many many jobs in cooloff).

Two changes here: The first simplifies the SQL and makes the SQL actually the same as the documentation (the previous implementation was not quite exactly the same), minus the removal of counting jobs in the *failed and *cooloff states. The second change just simplifies the SQL.