Sql Nested Case Syntax In C