Hi all,
Is it possible to give a sql query in the from clause befor the giving a table name.
for instance:-
select top 1 Salary from(select top 2 Salary from sstable order by Salary desc) aas
it is working but
my question is what is happening here
Whether a table is created virtually in the name aas
Is it possible to give a query in the from clause
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

DRISHTY134 reputationPosted May 24, 2010, 5:18 AM EDT
Select query in from clause is called derived table.
They are created on the fly and then use these derived tables within your query. In very basic terms, a derived table is a virtual table that's calculated on the fly from a select statement.
In concept this is similar to creating a temporary table and then using the temporary table in your query, but the approach is much simpler, because it can all be done in one step.
Venkatesan JayakanthamRank #256 · 9.8K reputationPosted Jun 6, 2010, 5:42 PM EDT
Cheers,
Venkatesan Prabu .J
http://venkattechnicalblog.blogspot.com/