Q:

Is there a syntax to query As fields that function data?

Is it possible to query a field name in SQL after using a function?
So for example
select datediff(hh, startdate, enddate) as HoursBetween
from tbl
where HoursBetween > 0

A:

Unfortunately, you cannot use ALIAS that was created on the same level with the WHERE clause because WHERE clause is being executed first before the SELECT clause. You have two choices,
One, use the expression directly in the WHERE clause.
select datediff(hh, startdate, enddate) as HoursBetween 
from tbl 
where datediff(hh, startdate, enddate) > 0

Two, wrap the statement in a subquery.
SELECT *
FROM
(
    select datediff(hh, startdate, enddate) as HoursBetween 
    from tbl 
) ss
WHERE ss.HoursBetween > 0

Here's the SQL Order of Operation:

FROM clause
WHERE clause
GROUP BY clause
HAVING clause
SELECT clause
ORDER BY clause

