Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread group by
Fri, Mar 30 2012 7:52 AMPermanent Link

Uffe Kousgaard

What is the correct way to express this in DBISAM 3?

select yearof(adatefield) as "year", sum(avaluefield)
from atable
group by year

I hope all understands what I want to happen.

Fri, Mar 30 2012 9:07 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Uffe

>select yearof(adatefield) as "year", sum(avaluefield)
>from atable
>group by year

SELECT EXTRACT(YEAR FROM adatefield) AS YEAR, SUM(avaluefield)
FROM atable
GROUP BY EXTRACT(YEAR FROM adatefield)

but I suggest you call the year something else since it clashes with one of Tim's keywords. It works but I'm always wary of things like that.

Roy Lambert [Team Elevate]
Mon, Apr 2 2012 11:20 AMPermanent Link

Robert Kaplan


"Roy Lambert" <roy@lybster.me.uk> wrote in message
news:57F4CF85-7387-4BD9-891B-F8F2B60CA098@news.elevatesoft.com...
> Uffe
>
>>select yearof(adatefield) as "year", sum(avaluefield)
>>from atable
>>group by year
>
> SELECT EXTRACT(YEAR FROM adatefield) AS YEAR, SUM(avaluefield)
> FROM atable
> GROUP BY EXTRACT(YEAR FROM adatefield)
>
> but I suggest you call the year something else since it clashes with one
> of Tim's keywords. It works but I'm always wary of things like that.

GROUP BY 1

would also work (group by the first field)

RK

Image