Re: Subqueries in SQL Server
- From: "Peter W. DeBetta" <debettap@xxxxxxxxxxx>
- Date: Fri, 12 Jan 2007 09:55:24 -0600
SELECT ENAME
FROM EMP
WHERE DEPTNO = 10
AND SUBSTRING(ENAME,1,4) = 'SAHU';
Why wouldn't you write the query like this? For all intents and purposes, it
is the same as you nested query (in both ORacle and SQL Server), but easier
to read, IMHO.
--
Peter DeBetta, MVP - SQL Server
http://sqlblog.com
--
<sangu_rao@xxxxxxxxxxx> wrote in message
news:1168578207.262940.268520@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
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';
The above one is a Oracle query, i want to know is there any equivalent
query in SQL server.
I don't want to write the query as
SELECT ENAME FROM EMP WHERE DEPTNO = 10 AND SUBSTR(ENAME,1,4) = 'SAHU';
Please provide your comments.
Thanks
Rao
.
- References:
- Subqueries in SQL Server
- From: sangu_rao
- Subqueries in SQL Server
- Prev by Date: how to set the Variables to a value in a asp script?
- Next by Date: Re: Cannot use openquery in SSIS
- Previous by thread: Re: Subqueries in SQL Server
- Next by thread: why my asp script failes to process DTS with access database connection?
- Index(es):
Relevant Pages
|