Hi folks,
In case the SQL statement is not written properly, we sometimes get strange
messages. The 2 following statements are simple inversion between order by
and group by clause. We get an "advice" about expected from or from_clause,
why ?
db2 select workdept, count(*) from employee order by 1 group by workdept
SQL0104N An unexpected token "select workdept, count(*) from employ" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<from_clause>". SQLSTATE=42601
db2 select workdept, count(*) from employee order by workdept group by
workdept
SQL0104N An unexpected token "select workdept, count(*) from employee orde"
was found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<from>". SQLSTATE=42601
Regards,
Jean-Marc
Serge Rielau - 11 Jan 2006 22:11 GMT
> Hi folks,
>
[quoted text clipped - 13 lines]
> was found following "BEGIN-OF-STATEMENT". Expected tokens may include:
> "<from>". SQLSTATE=42601
The GROUP BY clause has to come before the ORDER BY.
So the -104 (syntaxerror) is expected (the tokens are not terribly
useful I admit)
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab