Using an Alias column in the where clause in ms-sql 2000

后端 未结 2 595
离开以前
离开以前 2020-12-03 08:35

I know you cannot use a alias column in the where clause for T-SQL; however, has Microsoft provided some kind of workaround for this?

Related

2条回答
  •  Happy的楠姐
    2020-12-03 08:59

    One workaround would be to use a derived table.

    For example:

    select *
    from 
       (
       select a + b as aliased_column
       from table
       ) dt
    where dt.aliased_column = something.
    

    I hope this helps.

提交回复
热议问题