Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 AdventureWorks practise questions - esp correlated

Author  Topic 

John1234567
Starting Member

1 Post

Posted - 2014-05-21 : 08:32:14
I am trying to hone my TSQL skills. I have downloaded the AdventureWorks database, but I could do with some example questions, the kind I would be asked in a real world business. Does anyone know of a list of questions out there for this database?

I am particularly interested in correlated subqueries. I adapted a question that a book I have presented. But in answering it I figured I could just use a left join and filter on the NULLS - I didn't need to use a correlated subquery. So I didn't get to practise one, and I still don't know when I would use them, or how my brain process would work if I was presented with a question that required a correlated subquery as opposed to a join (if there is such a thing).

The question was something like, "Make a query where you select all the clients that have no orders" and I did this on a non-adventure works database with something like:

SELECT * FROM [User] LEFT OUTER JOIN [Orders] ON [Orders].[userid] = [user].[id] WHERE OrderPlaced IS NULL

I would like to get my hands on some examples where the only way to solve it is by using a correlated subquery, so that I'm forced into doing it that way and figuring it out that way in my mind.

Thank you in advance.

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-05-21 : 08:48:21
Simple-talk.com usually has good articles and examples. This article by Robert Sheldon (whose style of explaining is very good) might be useful. https://www.simple-talk.com/sql/sql-training/subqueries-in-sql-server/
Go to Top of Page
   

- Advertisement -