Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

To convert Oracle Query to SQL SERVER Query

Posted on 2004-03-23
3
Medium Priority
?
1,358 Views
Last Modified: 2012-05-04
Hi There ,
I've got this query which runs in Oracle , but the same query doesnt work in SQL Server

Select deal_no , deal_date
From (Select deal_no , deal_date From deals_hdr Where deal_no > 5000) ;

Is it possible to convert this query to ORACLE

Cheerio
Saju

0
Comment
Question by:sajuks
[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
3 Comments
 
LVL 33

Author Comment

by:sajuks
ID: 10656533
Select deal_no , deal_date
From deals_hdr where  exists (Select deal_no , deal_date From deals_hdr Where deal_no > 5000) ;

will work.
 I want to know why oracle allows the above query while sql server does not.
0
 
LVL 1

Accepted Solution

by:
raje10410 earned 500 total points
ID: 10656603
Hi Saju

Change your query as shown below. It'll surely work in SQL Server.

Select deal_no , deal_date
From (Select deal_no , deal_date From deals_hdr Where deal_no > 5000) AS DH ;

The trick is you refer the subquery by an alias. SQL Server has been designed to accept it only in this format.

Cheers,

Rajesh
0
 
LVL 33

Author Comment

by:sajuks
ID: 10673862
Thanks Rajesh .
It works perfectly, any idea how to get the same thing working in Sybase?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

597 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