Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

Why do I see a SELECt within a Inner Join clauses

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
upobDaPlaya
Asked:
upobDaPlaya
  • 3
  • 2
1 Solution
 
dbaSQLCommented:
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
 
upobDaPlayaAuthor Commented:
Got it..In your example is Production the name of the database and product the name of the table
0
 
dbaSQLCommented:
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
 
upobDaPlayaAuthor Commented:
Awesome..thanks for the reference also relative to the Objects !
0
 
dbaSQLCommented:
My pleasure.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now