• sknox (6/23/2011)


    .... the where condition filters the input to the aggregate functions, not the output from them.

    ...

    True. And of course this is because the Where clause filters input to the Select, regardless of it using an aggregate function. That's why one may not use an alias in the Where clause.

    This code wouldn't work because MyData is not a real columnName in table MyVeryLongTableName.

    Select tbl_a.RidiculouslyComplicatedColumnName as MyData

    from MyVeryLongTableName tbl_a

    join AnotherVeryLongTableName tbl_b on tbl_b.key = tbl_a.key

    where MyData = 'SearchString'