Hi Greg,
Thanks for your reply.
Yes, same group of code...
Perfect solution, simple and efficient. Thank you very much!!!
Cheers,
Rodrigo Carvalhaes
Greg Sabino Mullane wrote:
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
I need an subtotal for all the products with the same group and
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
> I need an subtotal for all the products with the same group and that the
> query be ordered by the bigger subtotal.
(please proofread: the subtotals in your example output did not add up)
By "same group" I presume you mean the same code, as you d
ered by the
bigger subtotal groups, indepent of the order of the codes...
Do you have any idea how I can do it?
Thanks,
Rodrigo Carvalhaes
Gnanavel Shanmugam wrote:
This might work,
select * from (SELECT * FROM product_sales()) t order by t.code
desc,t.subtotal;
with regards,
S.Gnanavel
--
92190 | PRODUCT b |20 | 0.8 | 8 | 41
>
> Any tip?
>
> Regards,
>
> Rodrigo Carvalhaes
>
>
> Gnanavel Shanmugam wrote:
>
> >I think it will be better to add one more column for subtotal and
> >write an "on before insert" trigger to update the subt
t; trigger to update the subtotal with sum of
total.
-Original Message-
From: [EMAIL PROTECTED]
Sent: Thu, 16 Jun 2005 00:56:42 -0300
To: pgsql-sql@postgresql.org
Subject: [SQL] SELECT with sum on groups ORDERING by the subtotals
Hi Guys!
I need to make a complex query. I am thinking
sql-sql@postgresql.org
> Subject: [SQL] SELECT with sum on groups ORDERING by the subtotals
>
> Hi Guys!
>
> I need to make a complex query. I am thinking to use plpgsql BUT I am
> confused how I can solve this.
>
> What I have:
> CREATE TABLE test
> (
> code varc
Hi Guys!
I need to make a complex query. I am thinking to use plpgsql BUT I am
confused how I can solve this.
What I have:
CREATE TABLE test
(
code varchar(15),
description varchar(60),
group varchar(10),
quant float8,
price float8,
total float8
)
WITHOUT OIDS;
INSERT INTO test (code, d