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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 index question

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_transactions
where 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
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2005-03-23 : 10:54:53
What do you think?



-------
Moo. :)
Go to Top of Page

phaze
Starting Member

42 Posts

Posted - 2005-03-23 : 11:45:32
intersting...i will do some research
Go to Top of Page
   

- Advertisement -