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