Case when exists sql. if exists statement between a case when condition sql.

Case when exists sql. Case statement in SQLite.