Parse Error: line 2:45 cannot recognize input near 'DISTINCT' 'substr' '(' in select expression