1. We sell music to our members. Employees recommend titles by rating them from1 to 5 with 1 being not very good to 5 being very good
What would your strategy be to write SQL code for the following query: "Show the members and the title and price for each of the products they bought."
I would use a left outer join |
||||||||||||||
I would not use a join because the data comes from one table |
||||||||||||||
I would use an equality join to find matching records in two or more tables by matching primary and foreign keys |
||||||||||||||
I would use a subquery |
||||||||||||||
I would use a recursive join to join a table to itself 2. We sell music to our members. Employees recommend titles by rating them from1 to 5 with 1 being not very good to 5 being very good How many tables would be needed to write the following query: "Show the average rating that each employee has given for all the products that employee has rated"
|
I would assume the below tables in this scenario:
Table titles - this table will have title, price and title name
Table title_ratings - this table will have title and employee ratings with employee name
Table members - This table will have memeber details
Table orders - this table will have member id and titles bought
1. I would use an equality join to find matching records in two or more tables by matching primary and foreign keys
We can join tables membera, orders and titles to get the info we need
2. 1
We just need data from table title_ratings to group by employees and get an avg rating per user.
Get Answers For Free
Most questions answered within 1 hours.