Example Sql Case Statement With Multiple Conditions In A While Loop