Solved

Why do I see a SELECt within a Inner Join clauses

Posted on 2014-02-01
5
336 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
[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
  • 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

How our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

740 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