Any help would be greatly appreciated. select Id, ( select case when. I' ve formatted your code and removed some redundant parentheses. I' ve added max( ) on a column you don' t have in your GROUP BY. The script does not begin with a shebang line, so the system executes it with / bin/ sh. On Ubuntu, / bin/ sh is dash, a shell designed for fast. SYMPTOM: Syntax error near unexpected token. SYMPTOM: Bad interpreter. SYMPTOM: Attempting to run a bash shell script received from another source. tbuild is a TPT ( Teradata Parallel Transporter) CLI, in the same manner bteq is a query CLI. You execute it from the command line, not from.