Question: How to trim first three characters of a column in select query in DB2?. I tried below query but did not work 

```
SELECT
MIN(Column1),UPPER(RIGHT(Column2, LENGTH(Column2 - 3))) AS TEST
FROM TEST_TABLE
GROUP BY UPPER(Column2)
ORDER BY UPPER(Column2);

```

I got below exception

```
The statement cannot be processed.

User response: 

Correct the statement by including the expression in the GROUP BY clause
that are in the SELECT clause, HAVING clause, or ORDER BY clause or by
removing the column function from the SELECT statement.

 sqlcode: -119

 sqlstate: 42803

```

Answer: 
You can simply use substring function to do the same.

```
SELECT
MIN(Column1),substr(Column2,4) AS TEST
FROM TEST_TABLE
GROUP BY UPPER(substr(Column2,4))
ORDER BY UPPER(substr(Column2,4));

```
Just do:

```
SELECT
MIN(Column1),UPPER(substr(Column2, 4)) AS TEST
FROM TEST_TABLE
GROUP BY UPPER(substr(Column2, 4))
ORDER BY 2;

```