Issue 18845: Cleaned up sql case statement in view