Re: why I can't group by an expression
Posted in 1997
SaTriGuy — — source: Informix-list mailing list archive (1991-1998)
>I have to use month(date) to get the month, but I can't use
>
>"group by region, month(date)" to create the summary table.
>
>
>
>My SQL looks like:
>
>
>
>insert into sum_mon_reg>
> select region,>
> sum(sales) sum_sales,
>
> month(date) date
>
> from sales
>
> group by region, month(date)
>
>
>
>then system reports "syntax error"
>
>
>
>What is the simplest way to solve this problem?
Try
Select region, sum(sales) sum_sales,
month(date) date
from sales
group by 1, 3>
>I know I could add another table with two fields:date and their
>
>corresponding month to solve this.
>
>
>
>But any simpler way?
>
>
>
>Your help will be most appreciated.
>
>
Madison Pruet