.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

How to take sum of rows data where certain rows data are same ?

Posted By:      Posted Date: September 26, 2010    Points: 0   Category :ASP.Net


perhaps title of my query is not clear.

	A	6	8	90
	B	6	8	3
	B	3	4	5
	A	12	23	43
	A	33	43	1
	B	3	4	3
	A	3	0	2
	B	43	55	3
	C	6	4	3
	A	4	5	3
	A	3	4	1
	C	4	1	56
	C	34	23	2
	B	1	2	3
	C	3	4	2
	A	3	23	43
	C	23	2	3

 above is the data in my Dataset's table. My requirement is that based on the first column's value where first column's values in one row matches with that of next row i have to take sum of other column values and delete the repeated rows.

for example, A in 0th row and 0th column matches with A in 3rd,4th,6th,9th,10th,15th row and 0th column.So take sum of all the corresponding values of 1st,2nd and 3rd column. And after that delete all rows that contains A except one row that contains the calculated value. This will happen for all other values in 0th column.Next will be for B,C and so on.


        A        64        106        183
        B        56         73         17
  ....and so on


this is the sample requirement that i need.1st,2nd and 3rd column are summed based on 0th columns equality.

In Linq how to achive this ?

View Complete Post

More Related Resource Links

MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Join 2 flat file data flows - retain unmatched rows

I have two data flows from two separate flat files. They may contain matching IDs (account number), in this case specific data from each flow should be used to create one row. When there is no match, the rows would stand on their own. At the end of the flow, I need both flows combined into one flow, with one record for each key record (account number). If I were able to use a look-up, I could easily union the no-match data flow back into the match data flow and have the desired result. I cannot use a look-up, since the source is flat files, but this is exactly the functionality I am trying to achieve. Solutions I want to avoid: staging tables, and cache transformations. Any ideas are appreciated.

Expand rows in a data grid to show details in the same page

<asp:templatecolumn headertext="Purchase Order"> <headerstyle horizontalalign="center"></headerstyle> <itemstyle horizontalalign="center"></itemstyle> <itemtemplate> <%# DataBinder.Eval(Container.DataItem, "PurchaseOrder") %> </itemtemplate> </asp:templatecolumn> <asp:templatecolumn headertext="Order"> <headerstyle horizontalalign="center"></headerstyle> <itemstyle horizontalalign="center"></itemstyle> <itemtemplate> <a href="OrderDetail.aspx?Order=<%# DataBinder.Eval(Container.DataItem, "OrderNumber")%>"> <%# DataBinder.Eval(Container.DataItem, "OrderNumber") %> </a> </itemtemplate> </asp:templatecolumn> <asp:templatecolumn headertext="Ack Date"> <headerstyle horizontalalign="center"></headerstyle> <itemstyle horizontalalign="center"></itemstyle> <itemtemplate> <%# DataBinder.Eval(Container.DataItem, "AcknowledgeDate") %> </itemtemplate> </asp:templ

ASP.NET Events and Pageload not firing when Datagrid containing large number of rows of data

Hi All, I have a datagrid in aspx page.Inside of datagrid i am using around 15 controls such as Button,dropdownlist and text box controls.Once the datagrid binds then the events in the aspx page not firing.Issue occured when the number of rowsgreater than 500.The number of rows less then its works fine.If anybody knows the solution please let me know."Platform i am working on ASP.NET1.1"Regards Hareesh

Hiding rows/columns completely in SSRS tablix even when they have data

I have several columns and rows in my tablix.  I don't want to see all of them at once.  I am using a parameter that controls the visibility of the columns or rows of the tablix.  The issue is that it hides but the white space is left.  How do i take out that white space?

Convert excel rows wise data into column wise


public static string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";

               OleDbDataAdapter adapter = new OleDbDataAdapter();

            OleDbCommand selectCommand = new OleDbCommand("SELECT * FROM [Sheet1$]");

            OleDbConnection connection = new OleDbConnection(connectionString);

            selectCommand.Connection = connection;

            adapter.SelectCommand = selectCommand;

            DataSet cities = new DataSet();


Concatenating several rows data into one field Visual Studio 2008


Below is my a example of my table and data.  I am using Visual Studio 2008.  I need to concatenate field customer_report with like field ‘number’.  I added a new SQLDataSource and put the query below into it.


Select Main.number,

       Left(Main.CustomerNotes,Len(Main.CustomerNotes)-1) As "CustomerNotes"

From(Select distinct PS2.number, 

           (Select PS1.customer_report + ',' AS [text()]

expanding data gird rows and binding gird


how do i display records by group wise in data gird

i have two tables

table1 Category

Pkid            name        

1             General      

2             Local      

table2 CatDetails

pkid          fkCategoryId           name

1                    1                           abcccc

2                    1                         kjlfdsjklk

3                    1      &n

how to insert data present in different rows of same collumn of one table into same rows of differn



I am have task that i have to insert data present in different rows of same collumn of one table into  same rows of differnt collumn of other table below shows the table structure source & distination

c_date                c_balance

11/1/2010          100

11/2/2010          200

11/3/2010          300

     ----                ----

  -----                ---

12/1/2010          150

12/2/2010          300

12/3/2010          400

   ---                  ----

   ----                  ---

like above i have thousands of data with other collumns

now i have the detination structure  as

SSAS for heavy network data to serve around 12-15 million rows per day


I am a fresher with the analytics.

Presently, working on a system which tracks the data from Network giants like Bing, Google, Yahoo, Facebook etc. depending upon the profile of customers using our system.

So we our tracking data of around 5-6 million rows in a day. Apart from that, dimensions like Search Keywords and all also contain data of around 50-60 million of rows. Although, daily addition will be low in dimension tables, but it will keep on increasing as customers will increase. Tracking data is expected to grow beyond 15 million.

To provide analytics, I must have minimum of 3 months of data in a cube. To provide trends, it should increase to around 1-4 years (in our future road map).

Presently, I am suffering with fatal issues while processing a cube, like, "The operation cannot be completed because the memory quota estimate xxxx exceeds the available system memory yyyy" - while processing dimensions

Please guide with some good thought process how to manage such a huge data and provide analytics over it. As well throw some light over the approach to follow for testing cubes and data loading packages of ssis.

Please provide the links of articles/videos/blogs & name of books to discuss and decide design the analytics for data-extensive systems. Any kind of reading mater

Handling Labels in policy mgmt and how to get some internal data into own fields (rows)


Dear All,

I found a good way to print out several Doc-Properties in the Doc itself. It works fine with the "Labels" function. Now I could get all my self created fields, for example my own version comments and some of the internal fields like the version number. But some of them don't work, for example DocID.

Here the MS Technet text: "

You can add a label to a document to ensure that important information about the document is included when it is printed. To specify the label, type the text you want to use in the Label format box. You can use any combination of fixed text or document properties, except calculated or built-in properties such as GUID or CreatedBy. To start a new line, type the \n character sequence."

My first question: Where can I find out which (intern) fields can be used and which not ?


As I recognized the limitations I tried out to find a workaround. I believed that it could work by creating some new fields in which these values should be inserted. For example a new DocID field in which the ac

SSIS data flow task not loading all rows from sybase server



Using a data flow task I am trying to load data from a table in sybase server to sql server. There are approx 10000 rows in the sybase table, however for some reason which I am not able to find out, at random certain no of rows are getting inserted. e.g. in one run 800 rows then 200 rows etc.

Can somebody please guide me on this?

how to add multiple rows in a data table against a button click event


how to add multiple rows in a data table against a button click event, and then show it in a gridview

Deleting rows in the data source in ASP.NET?


I used statements like 'Update' and 'Insert Into' to change the data in my data source. Like I updated a certain field like this:

ds.Tables("tblUsers").Rows(2)(3) = "xyzzzz" 

and then I executed an sql statement on the same field like this: 

objCmd.UpdateCommand = new OleDbCommand

objCmd.UpdateCommand.CommandText = "Update tblUsers " & _

"SET City='xyzzzz' WHERE UserID=3"  

objCmd.UpdateCommand.Connection = Conn

And finally I update the data source:


(where objcmd is an instance of oledbdataadapter object)


What should I do to delete a record in my data source through asp.net (in VB) with the same technique as above? The data source that I am using is MS Access. Please, help. 

How to update a variable in Data Flow component of lookup has rows that don't find matches



I'm using SSIS 2008

I have a data flow that gets data from an Excel spreadsheet. It then does numerous lookups to my database to ensure that all the entities in the spreadsheet are present in my dimension tables. For each of these lookups, I redirect rows with "no matching entries" to be written to another spreadsheet which is then sent to an email address for action.

I have a Package scoped variable that I want to update if any of the lookups have rows with no matching entries. This is used later in the package to determine if it should proceed or not. So this variable only needs to be updated once if any of the lookups fail. 


What are the options for doing this? What is the best way?


Craig Bryden - Please mark correct answers

How to insert column wise data as a seperate rows using ssis


Hi All,

I have my data in excel like this ....


add data rows from gridview..


   I am trying to add checked rows's ID in Gridview to a data table ( memory) .so I can use it for other process..


But it only add the ID from the last checked row in gridview.( for excample, I checked three rows , it only add the last checked rows to a data table) what am I doing wrong? How can I fix this?


        protected void LinkButton_AddNewUser_Click(object sender, EventArgs e)



            DataTable dt = new DataTable();





            DataRow dataRow;

            dataRow = dt.NewRow();



            for (int i = 0; i <= GV_NewUser.Rows.Count - 1; i++)

                    foreach (GridViewRow di in GV_NewUser.Rows)


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend