Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Not getting the meaning of the mention question exactly , Need help

In a car database there is a Sale table with columns, SaleID, CarID, CustomerID, LocationID, SalesRepID, SaleAmount and SaleDate and a Car table with columns, CarID, ModelID, VIN, ModelYear and StickerPrice. Use a subquery along with IN to list all sales of cars with Sticker Price greater than $30000. Include all columns.

2 Answers

This is the solution that I had:

Select * From Sale Where sale.carid In (Select CarID from Car Where StickerPrice > 30000);

Hi,

Assuming i understand your question correctly then the way i'd work through something like this is:

  1. Identify the table relationship (in your case both tables have a CARID)
  2. Write your inner query first: >> Get CarID from Cars where StickerPrice is > amount
  3. Write your outer query: >> GET [require columns] from Sales where sales.carid in your subquery...

You'll probably have to wrap your inner query in parentheses!!

I've tried to write it down in pseudocode as much as possible without giving you the answer. Give it a shot and if you still need more help then reply with your current attempt.