This is a simple question that I'm hung up on. I want to know if I can create a column alias and then use it in my WHERE
clause, i.e.:
SELECT TRACTOR, CONVERT(VARCHAR, ORDER) AS NUMBER
FROM TABLE
WHERE NUMBER = '4'
Keep in mind this is just an example of what I'm trying to do. The query I'm running is a bit more complex, but just the basic idea of how to create a variable and then use it in a clause.
My question is about the aliased columns in the where clause. I have a query that looks for an invoice number in one database and matches it the first 7 digits of a field in another database. The query worked fine when we only had 6 digits but now that we have 7, I'm getting an error and I'm trying to rewrite the query in a different manner.