Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Performing a su...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 15425 of 16159
Post > Topic >>

Performing a sub-query in a SELECT SUM aggregate.

by peter.geoghegan86@[EMAIL PROTECTED] ("Peter Geoghegan") Apr 30, 2008 at 01:19 PM

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

-- 
Sent via pgsql-general mailing list (pgsql-general@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
 




 1 Posts in Topic:
Performing a sub-query in a SELECT SUM aggregate.
peter.geoghegan86@[EMAIL   2008-04-30 13:19:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Thu Jul 24 1:55:22 CDT 2008.