case clause

From: Hammy (Hammy_at_discussions.microsoft.com)
Date: 08/23/04


Date: Mon, 23 Aug 2004 11:17:02 -0700

Hi all,

In my query, I want to be able to put a conditional statement in the 'where'
clause.
For example,

select * from tbl_abc
where
case when fld1 > 100 then
 field2 = 3
else
 field2 = 4
end

This gives me an error.
Any help is greatly appreciated.
Thanks,

 



Relevant Pages

  • Re: case clause
    ... field2 = case ... > In my query, I want to be able to put a conditional statement in the ... > clause. ...
    (microsoft.public.sqlserver.programming)
  • Re: case clause
    ... I think I see what you're saying. ... > In my query, I want to be able to put a conditional statement in the ... > clause. ...
    (microsoft.public.sqlserver.programming)
  • Re: case clause
    ... Case is not a logic flow statement, it is an expression that returns a ... > In my query, I want to be able to put a conditional statement in the ... > clause. ...
    (microsoft.public.sqlserver.programming)
  • RE: Any good T-SQL quick reference recommended?
    ... The full syntax of the SELECT ... SELECT Clause ... Specifies the columns to be returned by the query. ... Specifies that duplicate rows can appear in the result set. ...
    (microsoft.public.sqlserver.programming)
  • RE: Xlocking with a select statement
    ... named query expression, order clause, update clause, lock option ... A result table or the underlying base tables are updateable if the query ... A lock can be requested for the ...
    (microsoft.public.sqlserver.programming)