Author |
Topic |
wsilage
Yak Posting Veteran
82 Posts |
Posted - 2014-09-25 : 12:10:57
|
Not sure if you can help me, but I have a query that I am trying to exclude a few things, but it is not working the way I want it too.I am still seeing "TR" in my clm_att5 field and "*R-TG" in my clm_skut fieldselect clm_id1, clm_84b, clm_rcvd, clm_cc1, clm_cc2, clm_cc3, clm_clir, clm_65a, clm_tchg, clm_nego, clm_sppo, clm_form, clm_att1, clm_att2, clm_att3, clm_att4, clm_att5, clm_chast, clm_skut, clm_stades, clm_adjto, clm_adjfmfrom impact.dbo.clmwhere clm_rcvd > = '01/01/2014'and clm_clir <> 3655 AND clm_stades = 'HOLD' AND ((clm_att5 <> 'TR' and clm_skut <>'*R-TG') or (clm_att1 <> 'NG' AND clm_skut <> '*R-NG')) what am I doing wrong?Thanks |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2014-09-25 : 12:21:57
|
If you with "*" mean a wildcard search, try thisSELECT clm_id1, clm_84b, clm_rcvd, clm_cc1, clm_cc2, clm_cc3, clm_clir, clm_65a, clm_tchg, clm_nego, clm_sppo, clm_form, clm_att1, clm_att2, clm_att3, clm_att4, clm_att5, clm_chast, clm_skut, clm_stades, clm_adjto, clm_adjfmFROM impact.dbo.clmWHERE clm_rcvd >= '01/01/2014' AND clm_clir <> 3655 AND clm_stades = 'HOLD' AND ( (clm_att5 <> 'TR' AND clm_skut NOT LIKE '%R-TG') OR (clm_att1 <> 'NG' AND clm_skut NOT LIKE '%R-NG') ) Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA |
|
|
wsilage
Yak Posting Veteran
82 Posts |
Posted - 2014-09-25 : 12:33:10
|
Actually that isn't a wildcard. The "*" is part of our data *R-TG |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-09-25 : 12:39:02
|
Consider:[code]((clm_att5 <> 'TR' and clm_skut <>'*R-TG') or (clm_att1 <> 'NG' AND clm_skut <> '*R-NG')) [/ode]Now imagine a row where clm_att5 = TR (so, not NG) and clm_skut = foobarThat would pass the second test and appear in your output |
|
|
wsilage
Yak Posting Veteran
82 Posts |
Posted - 2014-09-25 : 13:40:54
|
Thanks! |
|
|
|
|
|