A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Try another query:
SELECT ID2, BUILDING, max(cast(isnull(BUILDING_STATUS, 1) as int)) over (partition by BUILDING) as BUILDING_STATUS
FROM @T1
order by ID2
Although, it is not clear what to display if all values in a group are NULL.