Solved

SQL Server sub query

Posted on 2012-12-20
2
499 Views
Last Modified: 2012-12-20
New to SQL Server, need to write this sql statement (Oracle Format) in SQL SERver


SELECT count(*) FROM
(SELECT empno, ename, JOB, sal FROM emp)
0
Comment
Question by:mohammadzahid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
Steve Wales earned 500 total points
ID: 38711550
Do this:

SELECT count(*) FROM
(SELECT empno, ename, JOB, sal FROM emp) as a

Open in new window


SQL Server requires inline selects like that to be aliased, even if you're not using the alias in the columns being selected.
0
 
LVL 11

Author Closing Comment

by:mohammadzahid
ID: 38711565
Thank you. Solution worked as I was hoping.
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question