group by with sum and sum till max date

Поиск
Список
Период
Сортировка
От M. D.
Тема group by with sum and sum till max date
Дата
Msg-id 4E134CF2.1040304@turnkey.bz
обсуждение исходный текст
Ответы Re: group by with sum and sum till max date
Список 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 по дате отправления:

Предыдущее
От: Samuel Gendler
Дата:
Сообщение: Re: interesting sequence
Следующее
От: Kevin Crain
Дата:
Сообщение: Re: interesting sequence