September 8, 2006 at 10:53 am
Is there a function to return the first nonempty value from a list of values ?
Here is an example of a sql statement
SELECT CASE
WHEN ISNULL(ColumnA,'') <> '' THEN ColumnA
WHEN ISNULL(ColumnB,'') <> '' THEN ColumnB
WHEN ISNULL(ColumnC,'') <> '' THEN ColumnC
WHEN ISNULL(ColumnD,'') <> '' THEN ColumnD
END .....
Is there a function that returns the first nonempty column from (ColumnA, ColumnB, ColumnC, ColumnD) ? The number of columns to be checked will not be constant.
And the sql statement that I have is much more complex than this example.
September 8, 2006 at 11:16 am
I think this is what you are looking for
select coalesce(nullif(ColumnA,''),nullif(ColumnB,''),nullif(ColumnC,''),nullif(ColumnD,'')) from tab
But performance wise its too bad I guess
September 8, 2006 at 11:17 am
I don't think you'll find anything really fast in that query .
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply