I'm trying the following SQL query:
select (execution_end_timestamp - execution_queued_timestamp) as totalTime, execution_queued_timestamp from exec_queue
where execution_name like '%Generate%'
and execution_queued_timestamp > '2012-10-04 20:00:00.000'
having totalTime < '1900-01-01 00:00:06.000'
I've tried using the totalTime in the where and having clause and in both cases it doesn't work. I also tried datediff hoping that might work, but it had identical results.
Is there a trick where you can use a computed field in a where or having clause? Googling around hasn't turned up anything except in cases where an aggregating function is used.