Performing a sub-query in a SELECT SUM aggregate.

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Performing a sub-query in a SELECT SUM aggregate.
Дата
Msg-id db471ace0804300519r832a796rdce0ed7aa69223a9@mail.gmail.com
обсуждение исходный текст
Список pgsql-general
Hello,

I'm writing a large pl/pgSQL function to batch process raw sales
records into departmentalised totals, stored in a dedicated table. The
logical thing to do is to INSERT a conditional aggregate ( INSERT INTO
..... SELECT SUM CASE WHEN ...ELSE... FROM..... GROUP BY ....) INTO
that dedicated table.

However, I need to do things like INSERT special records into some
other table sometimes. For example, if the sales were made on credit,
I need to make a dedicated record of that in the credit accounts
table. I'd like to do this within the conditional aggregate, when it
encounters a record that requires it, because that's more logical,
direct and efficient, rather then do the aggregate and then do
separate,"special" things on the same data. Is this possible? If not,
could someone write some psuedo code that would accomplish the same
think efficiently using cursors or something?

Thanks,

Peter Geoghegan

В списке pgsql-general по дате отправления:

Предыдущее
От: "Gurjeet Singh"
Дата:
Сообщение: Re: inheritance. more.
Следующее
От: Robert Treat
Дата:
Сообщение: Re: How to modify ENUM datatypes?