group by with sum and sum till max date - Mailing list pgsql-sql

From M. D.
Subject group by with sum and sum till max date
Date
Msg-id 4E134CF2.1040304@turnkey.bz
Whole thread Raw
Responses Re: group by with sum and sum till max date  (Samuel Gendler <sgendler@ideasculptor.com>)
List pgsql-sql
This is a little hard to explain, and I'm not sure if it's possible, but 
here goes.

This is my query:
select year, month,
(select number from account where account.account_id = 
view_account_change.account_id) as number,
(select name from account where account.account_id = 
view_account_change.account_id) as account,
sum(amount) as amount
from view_account_change
where view_account_change.change_date >= '2010-01-01'
group by year,month,  number, account
order by year,month, number, account

I want to make an exception for the sum so that if the account number is 
less than 4000, I want a sum of all transactions until the last date of 
the group by.

the query for that would be:
Select sum(amount) from view_account_change where change_date > "max 
date in the group"

Is this possible?

Thanks,
Mark


pgsql-sql by date:

Previous
From: Samuel Gendler
Date:
Subject: Re: interesting sequence
Next
From: Kevin Crain
Date:
Subject: Re: interesting sequence