Adding column values
-
Hi All! i have column1 which has some values in it. i want column2 to calculate the sum of the values in column1 in each cell as shown below: CL1 CL2 10 10 25 35 32 67 12 79 56 135 what is the query i need to write in order to acheive this.pl help me out.thanking in advance!!!
-
Hi All! i have column1 which has some values in it. i want column2 to calculate the sum of the values in column1 in each cell as shown below: CL1 CL2 10 10 25 35 32 67 12 79 56 135 what is the query i need to write in order to acheive this.pl help me out.thanking in advance!!!
Since a databases work on the concept of sets of data there is no intrinsic order in which the data exists. The implementation of the database software may make it appear that data is in a certain order, but that cannot be relied upon. In order to do what you want, you must first find a way to determine order. That might be through a primary key you already have, but didn't mention, or the creation of a new column that defines the order of the rows.
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
Hi All! i have column1 which has some values in it. i want column2 to calculate the sum of the values in column1 in each cell as shown below: CL1 CL2 10 10 25 35 32 67 12 79 56 135 what is the query i need to write in order to acheive this.pl help me out.thanking in advance!!!
Ok, actually you can do this very easily. Simply use a reader to read all the values in column 1 and add them to the same variable. Then add the value of the new insert to that same variable. That variable will be you value for column 2. I can explain better if you don't understand.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
-
Ok, actually you can do this very easily. Simply use a reader to read all the values in column 1 and add them to the same variable. Then add the value of the new insert to that same variable. That variable will be you value for column 2. I can explain better if you don't understand.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
ExpertComing wrote:
Ok, actually you can do this very easily. Simply use a reader to read all the values in column 1 and add them to the same variable. Then add the value of the new insert to that same variable.
You haven't taken into consideration the order of the rows. The OP has given no indication of how he determines the order. So, how do you know you are reading the rows in the correct order? Remembers any order that the rows appear in the result set are merely a quirk of the implementation and not guaranteed.
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
-
ExpertComing wrote:
Ok, actually you can do this very easily. Simply use a reader to read all the values in column 1 and add them to the same variable. Then add the value of the new insert to that same variable.
You haven't taken into consideration the order of the rows. The OP has given no indication of how he determines the order. So, how do you know you are reading the rows in the correct order? Remembers any order that the rows appear in the result set are merely a quirk of the implementation and not guaranteed.
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
He is looking for a sum. With a addition(sum) order doesn't matter. 2+1=3 1+2=3
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.
-
ExpertComing wrote:
Ok, actually you can do this very easily. Simply use a reader to read all the values in column 1 and add them to the same variable. Then add the value of the new insert to that same variable.
You haven't taken into consideration the order of the rows. The OP has given no indication of how he determines the order. So, how do you know you are reading the rows in the correct order? Remembers any order that the rows appear in the result set are merely a quirk of the implementation and not guaranteed.
Upcoming events: * Glasgow: SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website
Oh, I understand what you mean now. Let me think about how to do it, I have an idea but I want to think about it to make sure that it will work.
The only way to speed up a Macintosh computer is at 9.8 m/sec/sec.