SQL Question!

  • Thread starter Thread starter Vincent Choy
  • Start date Start date
V

Vincent Choy

Can anybody know how to set alias after 'where'?
select 1 as A, 2 as B,A-B as C from tbl where =1
 
Ignoring the part "2 AS B" means that B can never equal 1 in your where
clause, I think what you're looking for is a subquery:

SELECT
A,
B,
A-B AS C
FROM
(SELECT
1 AS A,
2 AS B
FROM tbl
) MySubQuery
WHERE B = 1

Hope this helps!

Dunc
 
Back
Top