Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Case Statement

Status
Not open for further replies.

rstum2005

Programmer
Jun 9, 2005
117
US
If you were to want the ELSE [return value] to not show up at all what would you do?

any tips?



CASE [expression]
WHEN [value | Boolean expression] THEN [return value]
[ELSE [return value]]
END





"Success consists of going from failure to failure without loss of enthusiasm."
Winston Churchill~
 
something has to show up in the column...

Code:
case when column=1 then column else NULL end

not sure what you're wanting...

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
Id like every row with the NULL in it to not show up in the results.

Thanks

"Success consists of going from failure to failure without loss of enthusiasm."
Winston Churchill~
 
then I would put your case criteria in the where clause...

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
let me rephrase.

Code:
(SELECT top 100 percent
'radius' = case when cast(t2.radius as numeric(10,0)) between 0 and 100 then '0 to 100' 
else null
end

results-

radius field field field
NULL 10004753 0 0

I dont want this to show in my results
I already have tried adding radius is not null to my where clause.

"Success consists of going from failure to failure without loss of enthusiasm."
Winston Churchill~
 
i only posted a little fragment of the code so i could not do that.

"Success consists of going from failure to failure without loss of enthusiasm."
Winston Churchill~
 
I figured it out..

it was pulling -1 radius fields and placed the null in there so I just added "where radius > '-1'" in the where clause

Thanks for all the responses.

"Success consists of going from failure to failure without loss of enthusiasm."
Winston Churchill~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top