Solved

Why do I see a SELECt within a Inner Join clauses

Posted on 2014-02-01
5
320 Views
Last Modified: 2014-02-01
I was reviewing someone's SQL code within MS Excel that really has me puzzled.  

It shows:
INNER JOIN(SELECT CUSTOMER.AC,",CUSTOMER.[OrderDate]
FROM CUSTOMER
WHERE[Status]='Current' AS CLIENT
ON....

Can someone help me with whats going on relative to these lines ?  Why is SELCT not its own line ?
0
Comment
Question by:upobDaPlaya
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:dbaSQL
ID: 39826953
Looks to me like you're just missing the top part of the query.  See this example, with a top query INNER JOINed to a subquery.


SELECT p.Name, s.OrderQty
FROM Production.Product p INNER JOIN (      SELECT ProductID, OrderQty
                                                                       FROM Sales.SalesOrderDetail) s
                                                                        ON p.ProductID = s.ProductID
0
 

Author Comment

by:upobDaPlaya
ID: 39826983
Got it..In your example is Production the name of the database and product the name of the table
0
 
LVL 17

Accepted Solution

by:
dbaSQL earned 500 total points
ID: 39826988
In my example, Production is the schema name, and Product is the table name.  Same with Sales.SalesOrderDetail.  Sales is the schema name, SalesOrderDetail is the table.

These objects exist in AdventureWorks2012.
0
 

Author Closing Comment

by:upobDaPlaya
ID: 39827063
Awesome..thanks for the reference also relative to the Objects !
0
 
LVL 17

Expert Comment

by:dbaSQL
ID: 39827113
My pleasure.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

912 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now