• You could use a simpler method than cte: subquery. This basic technique exists from sql2000 (and probably even earlier)

    and is worth to be learned:

    SELECT *

    FROM

    (

    SELECT A.COMPKEY, B.HYDR_ID, B.DATE, B.hydr_gpm, B.gpm_20, B.gpm_10, B.gpm_0, B.staff_id, B.shift,

    B.static, B.residual, B.pitot, B.pitot2, coeff, A.Shape, C.not_in_srv, A.FLOWTEST,

    Rank() over (Partition BY B.HYDR_ID order by B.DTTM DESC) AS RANK

    FROM GISOWNER.WATHYDRANT A

    LEFT JOIN S_4.FH.dbo.hyd_actv B

    ON A.COMPKEY = B.HYDR_ID

    LEFT JOIN S_4.FH.dbo.hyd_main C

    ON A.COMPKEY = C.HYDR_ID

    WHERE A.FIREZONE IN ('FZ1', 'FZ2', 'FZ3', 'FZ4', 'FZ5', 'FZ6', 'FZ7') AND (B.FLOWTEST = '1' OR C.not_in_srv = '1')

    ) FLOWTEST

    WHERE RANK = 1

    CTE is required only if you want to use a subquery more than once, or in a recursion.

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths