Question: [10 marks] Provide the correct SQL statements for the following three questions using the ERD schema shown below. Part A. Write a SQL statement to

[10 marks] Provide the correct SQL statements for the following three questions using the ERD schema shown below. Part A. Write a SQL statement to show customer names and addresses for customers who have placed orders in 2022 (i.e. placed orders this year). Customers should show up only once if they have orders in 2022. (4 marks) Part B. Write the SQL to add a new table called "Recalls" that has four columns ( r id, r code, r_text, p_id). rid is the primary key and should be created so that it's value is created automatically by the database server. p id refers to the primary key in the Products table and should be treated as a foreign key. Decide for yourself what the proper data types are for all the columns. (2 marks) Part C. Write a SQL statement to show product sales activity. Display the p_name and total sales for that product, ordered from the product with the most sales to the least sales. Include products that have zero sales. NOTE: Product names are not unique. (4 marks) \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Products } \\ \hline p_id \\ p_name \\ p_price \\ p_description \end{tabular} \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Orders } \\ \hline o_id \\ o_date \\ c_id \\ \hline \end{tabular} \begin{tabular}{|l|} \hline Order_Details \\ \hline od_id \\ od_quantity \\ o_id \\ p_id \end{tabular}\begin{tabular}{l} Customers \\ \hline c_id \\ \hline c_name \\ c_address \\ \hline \end{tabular}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
