Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Filter out values in query

Author  Topic 

Petronas
Posting Yak Master

134 Posts

Posted - 2008-11-12 : 17:10:51
The query pulls the follwing data

Customer Period
<null> 1 Year
Lozez 1 Year
<null> Monthly
afl=CA Monthly
afl=CD Monthly

I need to modify the query so that all the Customer =<null> and Customer NOT LIKE 'afl%'should be displayed as <null> , only see the Customers LIKE 'afl%'.

Thanks in advance,
Petronas.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-11-12 : 17:14:43
quote:
Originally posted by Petronas

The query pulls the follwing data

Customer Period
<null> 1 Year
Lozez 1 Year
<null> Monthly
afl=CA Monthly
afl=CD Monthly

I need to modify the query so that all the Customer =<null> and Customer NOT LIKE 'afl%'should be displayed as <null> , only see the Customers LIKE 'afl%'.

Thanks in advance,
Petronas.



Case when Customer is null or Customer not like 'afl%' then null else Customer End
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-12 : 23:06:34
by <null> did you mean NULL value in sql or it is just a string value '<null>'? both are different
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-13 : 01:36:00
Case when Customer like 'afl%' then Customer else null End

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2008-11-17 : 06:16:09
case when customer is null and Customer not like 'afl%' then null else Cutomer like 'afl%' end

I Struggle For Excellence
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-11-17 : 07:21:13
quote:
Originally posted by Nageswar9

case when customer is null and Customer not like 'afl%' then null else Cutomer like 'afl%' end

I Struggle For Excellence


This is syntaxically incorrect

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -