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.
| Author |
Topic |
|
Petronas
Posting Yak Master
134 Posts |
Posted - 2008-11-12 : 17:10:51
|
| The query pulls the follwing dataCustomer Period <null> 1 Year Lozez 1 Year <null> Monthly afl=CA Monthlyafl=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 dataCustomer Period <null> 1 Year Lozez 1 Year <null> Monthly afl=CA Monthlyafl=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 |
 |
|
|
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 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-13 : 01:36:00
|
| Case when Customer like 'afl%' then Customer else null EndMadhivananFailing to plan is Planning to fail |
 |
|
|
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%' endI Struggle For Excellence |
 |
|
|
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%' endI Struggle For Excellence
This is syntaxically incorrect MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|