Richard Broersma Jr wrote:
> --- Jan Danielsson <jan.m.danielsson@gmail.com> wrote:
>> ----------------------
>> select date_part('year', dt) as year, date_part('week', dt) as week,
>> sum(amount) as asum
>> from transactions
>> group by year,week
> having asum = (
> select max(A.weeksum)
> from
> (
> select sum(amount) as weeksum
> from transactions
> group by date_trunc('week', dt)
> ) A
> )
>> order by year,week;
>> ----------------------
>
>
> This should do what you want, but I expect that there is a better answer.
Hmm... This gives me:
ERROR: column "asum" does not exist
LINE 5: having asum = (
Any ideas?
--
Kind regards,
Jan Danielsson