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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using SUM fuction

Posted By:      Posted Date: October 15, 2010    Points: 0   Category :ASP.Net

Hi, I have a page which allows users to record cycling mileage. After each journey user enters mileage into web form which populates an SQL table. User can enter mileage into either Recreation field or Commute field  or Both.

There is also a Grid view on the page which displays total mileage entered by each user, it is ordered from highest to lowest mileage so user with most mileage is at the top of the list and the fewest at the bottom.

This is achieved using the following SQL command:

SelectCommand="SELECT Name, SUM(IsNull(Mileage,0)) + sum(IsNull(RecMileage,0)) FROM mileage GROUP BY Name ORDER BY SUM(IsNull(Mileage,0)) + sum(IsNull(RecMileage,0)) Desc"

I would like to create a new command which only targets mileage by certain users, so for example if User1 total mileage is 200 and user2 mileage is 100 I want a gridview that reads Total 300. I've tried adding WHERE Name ="User1" to command and it's fine but can't make it work for two user names.

Any help is much appreciated.



View Complete Post

More Related Resource Links

Using MDX Fuction - Item()

I am trying to get March, June, September, December period for different years going forward. I am using the Item() function and it's not returning any values at all. Would you be able to help? Thanks.   Here's the code: MEMBER    [Measures].[Q4 Budget] AS (strtomember(@prm_currbud),[Period].[Period].CurrentMember.parent.FirstChild.Item(12),[Measures].[PCA Total Qty])

how can i load a window1.xaml form from click event fuction of a button

how can i load a window1.xaml form from click event fuction of a button
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