SQL Question!

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
 
D

Duncan Welch

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top