Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
keithroby
Starting Member
6 Posts |
Posted - 2008-11-19 : 08:26:25
|
| I have a table full of course dates, instructors, courses and a series of 'scores' for a range of likert responses (1-5).Ultimately I'm going to pass this view to a SQLDataSource in asp.net, but what would the view be on the Server side?I want to be able to perform an AVG function off a user-inputted date range, where if the user selected 2/1/2008 as a start date and 6/1/2008 as an end date, the return would be avg scores for all the records in between (or inclusive of those dates).Any input?Thanks! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-19 : 08:30:50
|
something likeSELECT AVG(YourField)FROM YourtableWHERE datefield BETWEEN @StartDate AND DATEADD(dd,1,@Enddate)... |
 |
|
|
keithroby
Starting Member
6 Posts |
Posted - 2008-11-19 : 12:24:04
|
| Thanks! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-19 : 12:26:53
|
welcome |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-20 : 01:56:40
|
| For accuracy, you may need to useSELECT AVG(YourField*1.0)FROM YourtableWHERE datefield BETWEEN @StartDate AND DATEADD(dd,1,@Enddate)MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|