Boolean Expressions in SQL Select list

前端 未结 4 805
死守一世寂寞
死守一世寂寞 2021-02-02 05:07

I want to create a SQL Select to do a unit test in MS SQL Server 2005. The basic idea is this:

select \'Test Name\', foo          


        
4条回答
  •  失恋的感觉
    2021-02-02 06:04

    You can also use:

    select 
        'Test Name', 
        iif(foo = 'Result', 1, 0)
    from bar 
    where baz = (some criteria)
    

    I know this was asked a while back, but I hope this helps someone out there.

提交回复
热议问题