Case Statement Sql Using Distinct