Sql Nested Case Syntax In Bash