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 |
|
phaze
Starting Member
42 Posts |
Posted - 2005-03-23 : 10:50:27
|
| Select account_number, avg(trans_amount)from db_example.dbo.money_transactionswhere trans_date >= '1/1/2000'If i was allowed to only have one index on this table, where would i place it to best optimize the performance for this query? What type of index would it use? How would i write the sql statement to create this index?? |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2005-03-23 : 10:54:45
|
| 1...I think you need a "group by" clause to have the avg function work.2. best column would depend on the data profile....ie which column would get you more unique record groups....only 2 sensible candidates are account_number or trans_date columns.3...sql to create index...search BOL |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2005-03-23 : 10:54:53
|
| What do you think?-------Moo. :) |
 |
|
|
phaze
Starting Member
42 Posts |
Posted - 2005-03-23 : 11:45:32
|
| intersting...i will do some research |
 |
|
|
|
|
|