hi
Hi
I have the data like this in temp table
SQL> Select sno, value from temp;
SNO Value
1 650.00
2 850.00
3 640.00
3 985.00
5 987.00
9 9864.00
7 875.00
Now, I want display the result like this...
SQL> Select sno, value, get_sum(value) as sum from temp;
SNO Value SUM
1 650.00 650.00
2 850.00 1500.00 --650+850
3 640.00 2140.00 --1500+640
3 985.00 3125.00 -- 2140+985
5 987.00 4112.00
9 9864.00 13976.00
7 875.00 14851.00
Any one can tell me query for this .. I don't want any procedure or
function...
Thanks & Regards
Penchal Reddy
Information transmitted by this e-mail is proprietary to Infinite Computer Solutions and / or its Customers and is intended for use only by the individual or the entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If you are not the intended recipient or it appears that this mail has been forwarded to you without proper authority, you are notified that any use or dissemination of this information in any manner is strictly prohibited. In such cases, please notify us immediately at info.in@infics.com and delete this email from your records.
Select sno AS "SNO",
SELECT value AS "VALUE",
get_sum(value) as SUM
from temp;
________________________________
From: pgsql-sql-owner@postgresql.org
[mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Penchalaiah P.
Sent: April 24, 2007 8:09 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] hi
Hi
I have the data like this in temp table
SQL> Select sno, value from temp;
SNO Value
1 650.00
2 850.00
3 640.00
3 985.00
5 987.00
9 9864.00
7 875.00
Now, I want display the result like this...
SQL> Select sno, value, get_sum(value) as sum from temp;
SNO Value SUM
1 650.00 650.00
2 850.00 1500.00 --650+850
3 640.00 2140.00 --1500+640
3 985.00 3125.00 -- 2140+985
5 987.00 4112.00
9 9864.00 13976.00
7 875.00 14851.00
Any one can tell me query for this .. I don't want any procedure or
function...
Thanks & Regards
Penchal Reddy
Information transmitted by this e-mail is proprietary to Infinite
Computer Solutions and / or its Customers and is intended for use only
by the individual or the entity to which it is addressed, and may
contain information that is privileged, confidential or exempt from
disclosure under applicable law. If you are not the intended recipient
or it appears that this mail has been forwarded to you without proper
authority, you are notified that any use or dissemination of this
information in any manner is strictly prohibited. In such cases, please
notify us immediately at info.in@infics.com and delete this email from
your records.
Hi,
try this. It's working...
SELECT t1.sno, sum(t2.value)
FROM temp as t1, temp as t2
WHERE t1.sno >= t2.sno
GROUP BY t1.sno;
but not completely. The problem is the this suppose your sno is uniqu. But as I see 3 is not.
Anyway it may help you.
I have the data like this in temp table
SQL> Select sno, value from temp;
SNO Value
1 650.00
2 850.00
3 640.00
3 985.00
5 987.00
9 9864.00
7 875.00
Now, I want display the result like this...
SQL> Select sno, value, get_sum(value) as sum from temp;
SNO Value SUM
1 650.00 650.00
2 850.00 1500.00 --650+850
3 640.00 2140.00 --1500+640
3 985.00 3125.00 -- 2140+985
5 987.00 4112.00
9 9864.00 13976.00
7 875.00 14851.00
Any one can tell me query for this .. I don't want any procedure or
function...Thanks & Regards
Penchal Reddy
Information transmitted by this e-mail is proprietary to Infinite
Computer Solutions and / or its Customers and is intended for use only by
the individual or the entity to which it is addressed, and may contain
information that is privileged, confidential or exempt from disclosure
under applicable law. If you are not the intended recipient or it appears
that this mail has been forwarded to you without proper authority, you are
notified that any use or dissemination of this information in any manner is
strictly prohibited. In such cases, please notify us immediately at
info.in@infics.com and delete this email from your records.
Show quoted text
On �ri, 2007-04-24 at 17:39 +0530, Penchalaiah P. wrote:
Hi
I have the data like this in temp table
SQL> Select sno, value from temp;
you seem to be assuming a specific order for this.
gnari
On Tue, 24 Apr 2007, Penchalaiah P. wrote:
Hi
I have the data like this in temp table
SQL> Select sno, value from temp;
SNO Value
1 650.00
2 850.00
3 640.00
3 985.00
5 987.00
9 9864.00
7 875.00
Tables are not ordered. You'll need something like an ordering column
that represents the ordering and is unique.
Then you can probably do something like (untested):
select sno, value, (select sum(value) as sum from temp t where t.ordering
<= temp.ordering) from temp order by ordering;
or
select t1.sno, t1.value, sum(t2.value) from temp as t1, temp as t2 where
t1.ordering >= t2.ordering group by t1.ordering, t1.sno, t1.value order
by t1.ordering;
Penchalaiah P. wrote:
Information transmitted by this e-mail is proprietary to Infinite Computer Solutions
It may be proprietary, but it shore ain't confidential!
John Summerfield wrote:
Penchalaiah P. wrote:
Information transmitted by this e-mail is proprietary to Infinite
Computer SolutionsIt may be proprietary, but it shore ain't confidential!
Placing "confidential" on every document without regard for its content,
especially when some of it's publicly disseminated, can remove the protection
of confidentiality at law from all such marked documents in many
jurisdictions, including the U.S. There must be discrimination applied in the
marking of information as "confidential".
Quite aside from the foolishness you pointed out of marking something
"confidential" then placing it into the public eye in an archived forum where
it will be visible by everybody forever.
Now we can publish everything ever written at or by Infinite Computer
Solutions without fear of liability.
--
Lew
[ redirected for a wider audience ]
Lew <lew@nospam.lewscanon.com> writes:
John Summerfield wrote:
Penchalaiah P. wrote:
Information transmitted by this e-mail is proprietary to Infinite
Computer SolutionsIt may be proprietary, but it shore ain't confidential!
Placing "confidential" on every document without regard for its
content, especially when some of it's publicly disseminated, can
remove the protection of confidentiality at law from all such marked
documents in many jurisdictions, including the U.S. There must be
discrimination applied in the marking of information as
"confidential".
Quite aside from the foolishness you pointed out of marking something
"confidential" then placing it into the public eye in an archived
forum where it will be visible by everybody forever.
Now we can publish everything ever written at or by Infinite Computer
Solutions without fear of liability.
Wow, that is a great argument that I've not seen before. The only
way we'll ever make a dent in the plague of legalistic disclaimers
auto-attached to email is if we can convince corporate lawyers that
there is a downside *to them* of insisting on the damned things.
This is the first argument I've seen that there might actually be
a serious legal downside to the practice.
Can you cite chapter and verse to back up this position? It'd be
great to have a well-reasoned FAQ document that people could just
automatically send to anyone exhibiting this folly ...
regards, tom lane