Khairy Abd el-Zaher Khairy Abd el-Zaher - 5 months ago 30
SQL Question

SQL Server Select with different where conditions for different field values

I want to select data from my table

which has a field called
and I need to apply different conditions to each type.

The code may look like this:

select * from offer where
if type = 1 then apply condition_1,
else if type = 2 then apply condition_2 and condition_3,
else if type = 3 then apply condition_4,

So how can I achieve that?

select * from offer
where (type =1 and condition_1 )
or ( type = 2 and condition_2 and condition_3 ) 
or (type = 3 and condition_3 )