if or case within a select [message #363019] |
Thu, 04 December 2008 15:52  |
nandac
Messages: 41 Registered: July 2006 Location: jersey city, usa
|
Member |
|
|
i got this sql :
select ts_name "TABLESPACE_NAME", status "Status", tssize "Size(MB)", used "Used(MB)", free "Free(MB)", percentagefree "%Free", (free * 90/100)/maxspaceused "Days to fill 90%" from tablespace_rep order by 7;
the last column if you notice is a computed column. if its value is null i want to print the value of the column "free" in its stead.
or
if maxspaceused is null or < 1, then i want to simply print the column "free". this will work as well.
how do it do this?
|
|
|
Re: if or case within a select [message #363020 is a reply to message #363019] |
Thu, 04 December 2008 16:09   |
knicely87
Messages: 25 Registered: December 2008 Location: Pittsburgh, PA
|
Junior Member |
|
|
Here is one way:
(CASE
WHEN (free * 90/100)/maxspaceused IS NULL
OR (free * 90/100)/maxspaceused < 0 THEN free
ELSE (free * 90/100)/maxspaceused
END) "Days to fill 90%"
Thanks,
Jim
|
|
|
|
|