user3669787 user3669787 -4 years ago 77
SQL Question

Tricky WHERE condition clause

I got into a dilema that seems to be easy but i just can't put it in TSQL.

Let's say I have this Table

Service Master
LOCAL BRGIL
EREPO CROMST
NICLI CROMST
EXPORT NIGIL


I need to disregard all records that in Master they have the value 'CROMST' unless the value in 'Service' is EREPO

so far i've tried

WHERE (Master <> 'CROMST' AND ([Service] <> 'EREPO'))


This only shows

Service Master
LOCAL BRGIL
EXPORT NIGIL


i have tried this also

WHERE (Master <> 'CROMST' AND (rtrim([Service])+rtrim(Master) <> 'EREPOCROMST'))


and still no luck.

I know this should be easy but i am blocked

the result i am looking is

Service Master
LOCAL BRGIL
EREPO CROMST
EXPORT NIGIL

Answer Source
SELECT * FROM 
your_table
WHERE (Key2 != 'CROMST' OR Key1 = 'EREPO' )

would be my approach

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download