GP: Answering Business Questions using SQL

Thank you, @Bruno and @hanqi!

Oh, my mistake, Bruno. I will keep this in mind in future questions.

That is exactly what I meant, hanqi! I didn’t know I could use an information from an outer query in an inner query. I always thought the subqueries had to be sufficient on their own. I will try to find some exercises regarding correlated subqueries before tackling this 191-7 project.

Use the search function here on Discourse to search for 191-7, there are other solutions around that do not use the this technique.

Hey, Bruno. I had run through these topics regarding 191-7. I had found another solution in:

The proposed solution counts the number of distinct tracks in an album and the number of distinct tracks in an invoice, compares both and considers it an album purchase if the numbers are equal, isn’t it?

However, can’t we have some false positives in doing so? I mean, cases when the number of distinct tracks in an invoice are the same number of tracks in an album but the tracks themselves are different? In this situation, the invoice will be called an album purchase but it should not be.

I am not sure if I misinterpreted the code, though.

Not quite. It’s the number of distinct tracks in each combination of invoice and album.

If you have further questions concerning that solution, please reply to the post where that solution is posted or create a new topic including the solution you wish to ask about.

Thanks, Bruno! :grinning:

1 Like

2 posts were split to a new topic: Answering Business Questions Using SQL

I am certainly no expert (yet - hopefully one day :slight_smile:), but this approach seems a lot more simple and intuitive to me than the solution given. I started going down this route, got stuck on some details, got very confused by the proposed solution and started thinking I was way off base… I went back and did it this way in the end. Thanks for your help!

1 Like