T-SQL syntax does not allow you to use a column defined in the SELECT list (in your case, the 'Out' column) anywhere else in that query except in the ORDER BY clause. This is because of the logical sequence in which SQL Engine processes the query. If you are interested in logical query processing phases, see here.So change your query to use the actual expression for 'Out' in the where clause as wellSELECT tblarInvoice.InvoiceNumber , tblarInvoice.Status , tblarInvoice.Customer , tblarInvoice.InvoiceToName , tblarInvoice.InvoiceAmount , tblarInvoice.PaidAmount , tblarInvoice.InvoiceDate , tblarInvoice.InvoiceDueDate , DATEDIFF(dd, InvoiceDueDate, GETDATE()) AS 'Out'FROM dbo.tblarInvoiceWHERE Status = 'open' AND DATEDIFF(dd, InvoiceDueDate, GETDATE()) > 40