Solved

Why do I see a SELECt within a Inner Join clauses

Posted on 2014-02-01
5
346 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

626 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