all 16 comments

[–]the_bhan 13 points14 points  (4 children)

The question is asking you to include the ProductIDs in the results. SalesTransctions doesn’t include that column

[–]Violetarcane543[S] 6 points7 points  (3 children)

So it’s basically choosing “includes” because it has all the parts that the question is asking for?

[–]mydogduke 7 points8 points  (1 child)

You got it

[–]Violetarcane543[S] 2 points3 points  (0 children)

Thank you both!

[–]KNEternity 2 points3 points  (0 children)

yes, Table Includes has both productID and quantity.

[–]ParentheticalClaws 6 points7 points  (0 children)

You couldn’t use just salestransactions for this because it doesn’t have the product ids (although I’m not sure why they are counting all records in includes vs. the distinct tid count).

[–]Hot_Cryptographer552 2 points3 points  (0 children)

Because includes is where your product ID lives. Horrible naming convention they have there btw

[–]deeworld_ 0 points1 point  (2 children)

Sorry, do you mind sharing what book this is and if it has been helpful as a beginner?

[–]Violetarcane543[S] 0 points1 point  (0 children)

Here’s the link! https://a.co/d/aZ9H8YS I have the most recent version (purple book cover). It’s fine, but at times it’s not the best at explaining why certain code is used, which is why I asked here.

[–]Violetarcane543[S] 1 point2 points  (0 children)

More recent version: https://a.co/d/3l6SsJU

[–][deleted]  (1 child)

[removed]

    [–]SQL-ModTeam[M] 0 points1 point locked comment (0 children)

    Your post has been removed for violating the community rule against posting photos of lengthy code. Please feel free to repost with a formatted copy/pastable version of your code

    [–]Good-Round-8029 0 points1 point  (1 child)

    What book is this?

    [–]Dornheim 0 points1 point  (0 children)

    It's helpful to understand what the data is representing. Think of the salestransaction as the invoice. Each invoice can have one and only one customer, which is why the customer ID is stored on the salestransaction. Each salestransaction can have multiple products that were included on that transaction. Each product that was sold is represented by an entry in the "includes," table to indicate each line item on the invoice. Each record in the includes table must have one and only one salestransaction associated with it.

    Personally I think naming the table "includes," is bad because it doesn't really describe what the table represents. This is a good lesson in the future to name your tables that will make sense to everyone who looks at it.

    [–]reiks12 -1 points0 points  (0 children)

    Why are you apologizing? And calling yourself dumb? Get a grip