Solved

Why do I see a SELECt within a Inner Join clauses

Posted on 2014-02-01
5
313 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Awesome..thanks for the reference also relative to the Objects !
0
 
LVL 17

Expert Comment

by:dbaSQL
Comment Utility
My pleasure.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
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…

744 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

16 Experts available now in Live!

Get 1:1 Help Now