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 |
WebKill
Starting Member
32 Posts |
Posted - 2014-06-25 : 15:25:26
|
This may be an easy answer, but I'm not sure how to phrase it so I am having trouble finding the answer.I have a select statement, lets take the following as an exampleselect case when field1 + isnull(field2,'') <> field3 then field1 end as comparefrom mytablewhere compare is not nullSo basically what I am doing is only showing the data for field 1 if the concatenation of field 1 and 2 is not the same as field 3, otherwise it will show null.What I want to do is use my custom named field and only display when its not null. Is this possible? I know how I have it written above doesn't work, but I was wondering if there is some way because it would make my query a lot cleaner.Thanks!Joe |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-06-25 : 15:31:29
|
select * from (select *, case when field1 + isnull(field2,'') <> field3 then field1 end as compare from mytable) twhere compare is not nullTara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
WebKill
Starting Member
32 Posts |
Posted - 2014-06-25 : 15:43:33
|
arg, of course, now I just feel silly. Thanks for reminding me of that!Joe |
|
|
|
|
|