Jan Danielsson <jan.danielsson@gmail.com> writes:
>    Essentially, I want:
> select dt,sum(amount) as asum where asum=(select max(asum) ...) group by dt
There are a couple ways you could do it:
* HAVING clause:
select dt,sum(amount) as asum
  group by dt
  having sum(amount) = (select max(asum) ...)
* ORDER BY/LIMIT:
select dt,sum(amount) as asum
  group by dt
  order by asum desc
  limit 1
The first is standard SQL, the second isn't (no LIMIT in the spec)
but the second is probably more efficient.
            regards, tom lane