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

--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply via email to