# How to get rid of Sort Cost ?

> Place the name of the column you use with order by at the end of the index.

**Query :**

```csharp
select ExceptionMessage, CreateDate from TableName
where MethodName = 'ERROR'
order by TerminalNo
```

**First index :**

```csharp
CREATE NONCLUSTERED INDEX [IX_TableName_MethodName] ON 
[dbo].[TableName] ([MethodName])
INCLUDE (TerminalNo, ExceptionMessage,  CreateDate) -- the columns that used by select statement
WITH (DROP_EXISTING = ON, ONLINE = On)
GO
```

**First Execution Plan :**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713172145755/b3ca5da5-1be1-4744-b6df-a21fb9784daa.jpeg align="center")

**Second index :**

```csharp
CREATE NONCLUSTERED INDEX [IX_TableName_MethodName] ON 
[dbo].[TableName] ([MethodName], [TerminalNo])
INCLUDE (ExceptionMessage,  CreateDate)
WITH (DROP_EXISTING = ON, ONLINE = On)
GO
```

**Second Execution Plan :**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1713172166103/6d743f66-70b3-431c-9566-9a603df8b4e0.jpeg align="center")

For more information about order by : [https://www.mssqltips.com/sqlservertip/1337/building-sql-server-indexes-in-ascending-vs-descending-order/](https://www.mssqltips.com/sqlservertip/1337/building-sql-server-indexes-in-ascending-vs-descending-order/)
