I have the following scenario(table below) where I would like to pick 'X' or 'Y' based on whether they are NULL or not.

```
  X         Y            pick
  null     not null        Y
  not null not null        X
  not null null            X

```

the rows containing the data 'X' and 'Y' or UNION ALLed like below:

```
  select 'X' as a
  union all
  select 'Y' as a

```

So I tried and got the following SQL but not sure about the "rownum<=1" part. This will work(for the case where both X and Y are not null) only if UNION ALL preserve 
the order in which I query the two rows.

```
  select a from 
  (
  select 'X' as a
  union all
  select 'Y' as a
  ) where a is not null and rownum<=1;

  select a from 
  (
  select null as a
  union all
  select 'Y' as a
  ) where a is not null and rownum<=1;

  select a from 
  (
  select 'X' as a
  union all
  select null as a
  ) where a is not null and rownum<=1;

```

Is the above right way to go about this?. Any insight would be much appreciated