Re: Subqueries in SQL Server



Is there any similar statement in SQL Server for the below Oracle query

SELECT ENAME FROM (SELECT ENAME FROM EMP WHERE DEPTNO = 10)
WHERE SUBSTR(ENAME,1,4) = 'SAHU';

Yes, these are called derived tables in SQL Server. Actually, if you change
the SUBSTR function to SUBSTRING, i think your query should work in SQL
Server.
In addition, SQL Server 2005 has also subqueries in the WITH prolog of the
SELECT statement called Common Table Expressions. They can be more
eefficient that derived tables, if you have to refer to the same subquery
more than once.

--
Dejan Sarka
http://www.solidqualitylearning.com/blogs/


.



Relevant Pages

  • Re: An odd quandry.
    ... Kinda like coalesce, but for subqueries? ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: Insert with multiple subqueries - possible?
    ... > Hi John, ... > VALUES clause. ... I get the same error, but your answer implies that SubQueries in ... Insert statements are possible, at least in SQL Server, which is positive. ...
    (microsoft.public.sqlserver.programming)
  • Re: problem with subselect
    ... I should point out that this is syntax that is proprietary to SQL Server ... table multiple times, it is unpredictable which value that will win. ... subqueries in the SET clause. ... Books Online for SQL Server 2005 at ...
    (comp.databases.ms-sqlserver)
  • Re: select statement
    ... Pro SQL Server 2000 Database Design ... "Roji. ... P. Thomas" wrote in message ... >> I try to do subqueries that in the top select I select ...
    (microsoft.public.sqlserver.programming)

Loading