Bash Nested Case Statement Sql Example