Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 A SELECT statement with just sub-selects?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

107 Posts

Posted - 11/06/2012 :  05:49:33  Show Profile  Reply with Quote
Hi all,

Is it possible to write a SELECT statement with just sub-selects? I don't need a FROM for a query I am writing.



(SELECT count(job.job_number)
job.job_number = job_status_log.job_number AND
job.job_log_number = job_status_log.job_log_number AND
job.job_status_flag = 'C' AND
job_status_log.status_code IN ('J020', 'J020', 'J040')) as Orders_Issued_Awaiting_Completion

Flowing Fount of Yak Knowledge

2167 Posts

Posted - 11/06/2012 :  06:26:32  Show Profile  Reply with Quote
So, why is this a nested select? Just select your count. Also, you should really use the LEFT JOIN, INNER JOIN syntax instead of joining in the where clause.

How to ask:

Go to Top of Page

Flowing Fount of Yak Knowledge

2242 Posts

Posted - 11/06/2012 :  06:26:35  Show Profile  Reply with Quote
It is not possible for sub-query..

You have to write FROM clause to get sub-query...

For your query, no need of outer SELECT at all know.......?

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000