Hi,
I have a problem with the following statement:
select to_char(datefield,'%Y-%m'), field2, sum( field3)
from testtable
group by to_char(datefield,'%Y-%m'), field2
I got the error "-201 A syntax error has occurred."
What is wrong? Am I not allowed to use the to_char function in the group by
statement?
Hope you can give me a hint.
--
Sven Heins
solution42 IT systems & consulting Gmbh & Co KG
http://www.solution42.de
↪ replying to Sven Heins
Sven Heins wrote:
>
> Hi,
>
> I have a problem with the following statement:
>
> select to_char(datefield,'%Y-%m'), field2, sum( field3)
> from testtable
> group by to_char(datefield,'%Y-%m'), field2
>
> I got the error "-201 A syntax error has occurred."
>
> What is wrong? Am I not allowed to use the to_char function in the group by
> statement?
Correct, just use the positional version of the group by clause:
select to_char(datefield,'%Y-%m'), field2, sum( field3)
from testtable
group by 1,2;
Art S. Kagel