SQL Server Interview Question #229
How do you decide the order of columns in a composite index?
Advanced Indexing Senior Advanced
Detailed Explanation
Column order should reflect the workload. Important factors include equality predicates, range predicates, join columns, required ordering, grouping, selectivity, and whether the query needs to use a useful leftmost prefix.
For example, if a frequent query filters by CustomerId and then a date range, an index on (CustomerId, OrderDate) may provide an efficient access path.
The simplistic rule 'put the most selective column first' is not always correct because sorting and predicate structure can be more important.