4 Replies - 797 Views - Last Post: 24 September 2012 - 07:56 AM Rate Topic: -----

#1 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

C# - SQL Query

Posted 21 September 2012 - 10:33 PM

I have a customer table it contains 100 records.
I used to have a gridview to show these records.
here my problem is i have to show only 11 records in gridview Ist 10 record should be top 10 customers and 11th record shows balance 90 customers total. In footer row i have to show whole 100 customers total

I need any efficient way to do this by c# or Sql

Thanks in Advance :)

Is This A Good Question/Topic? 0
  • +

Replies To: C# - SQL Query

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3574
  • View blog
  • Posts: 11,115
  • Joined: 05-May 12

Re: C# - SQL Query

Posted 21 September 2012 - 11:39 PM

Is it only going to be 100 records and never going to be much more than this?

I'm asking because, it will be quite easy to do this in C#, but you have to transmit 100 records to the C# code from the database. As opposed to doing all the computation from within the database, and then the database only sending back 12 rows.

So a 100 rows is pretty negligible with current datatabase and network speeds. Now if you start ramping up to 1000 rows and more then it really gets expensive to transmit that much data.

I assume that you are talking about the ASP.NET data grid and not the WinForms data grid because I don't think that the WinForms data grid has a footer row.
Was This Post Helpful? 0
  • +
  • -

#3 G_rose42  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 51
  • Joined: 15-December 10

Re: C# - SQL Query

Posted 22 September 2012 - 02:23 AM

Not only 100 records it may be more than 100.
yes, am using asp.net gridview.
in that i have to show top 10 customers and 11 record should be sum of balance records i ll put it as other customers
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,516
  • Joined: 23-August 08

Re: C# - SQL Query

Posted 22 September 2012 - 02:40 AM

Moved to ASP.NET
Was This Post Helpful? 0
  • +
  • -

#5 h4nnib4l  Icon User is offline

  • The Noid
  • member icon

Reputation: 1181
  • View blog
  • Posts: 1,675
  • Joined: 24-August 11

Re: C# - SQL Query

Posted 24 September 2012 - 07:56 AM

Then it should be pretty simple to control via a counter. For your first 10 records, bind the data to your gridview AND add it to some "total" variables. Once your counter tells you you're passed the 10th record, stop binding it and just add the data to the variables. Divide the variables' values by the counter, and then generate your final row using the averages.

This post has been edited by h4nnib4l: 24 September 2012 - 07:59 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1