Join with sqlite on table in android Given a table like:

object    subject    ID      parentID
------    -------   -----    --------
  A         NULL      1          0
  B         NULL      2          0
  C         NULL      3          0
  D         NULL      4          0
  E         NULL      5          0
 Null        CC       6          1
 Null        DD       7          2
 Null        EE       8          2


I need a query with good performance that returns the following result:

result
------
  A
  CC
  B
  DD
  EE
You can use coalesce, it's a function that returns its leftmost non-null argument:

select coalesce(object, subject) 
from t;


Coalesce is a shorter form of:

select case when object is not null then object else subject end
from t;