Case When Sql Multiple Subqueries