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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-01-04 : 11:29:03
|
| Rob writes "I have a situation where i am calculating the difference between two dates. The table looks like this. (TravelDate, BookDate,Cost)So far my string looks like..."Select Cost,dateDiff(d, bookdate,traveldate) as dateDifference from data"I want to eventually sum the total cost for each group of differences. For instance, sql server may return0 - $500 - $230 - $51 - $62 - $342 - $665 - $0so the sum cost for a date difference of 0 would be $78, for a date difference of 1 day, $6.. etc. I can't group by the alias, so is there any way to get the sum costs for the groups of days? Thankks for your time-" |
|
|
nricardo
Starting Member
17 Posts |
Posted - 2002-01-04 : 11:35:59
|
| group by dateDiff(d, bookdate,traveldate)Don't forget to SUM(cost)Edited by - nricardo on 01/04/2002 11:37:18 |
 |
|
|
|
|
|