QUESTION

Text
Image


C. Assume that a bookstore has 3 tables on their database, each table on author, book, and book sales, with samples of the data and columns as shown below. Please write an SQL query for each of the following problems. Turn in all the code that you write, and clearly state any assumption that you make (if any). Table 1: author \begin{tabular}{|r|l|r|} \hline id & author & birthaxear \\ \hline 1 & Jane Austen & 1900 \\ \hline 2 & Emily Bronte & 1901 \\ \hline 3 & Charlotte Bronte & 1902 \\ \hline 4 & Sylvia Plath & 1903 \\ \hline \end{tabular} Table 2: book \begin{tabular}{|r|l|r|r|} \hline id & title & publishingarear & authrsid \\ \hline 1 & The Bell Jar & 1980 & 4 \\ \hline 2 & Wuthering Heights & 1950 & 2 \\ \hline 3 & Pride and Prejudice & 1952 & 1 \\ \hline 4 & Jane Eyre & 1925 & 3 \\ \hline 5 & Persuasion & 1954 & 1 \\ \hline \end{tabular} Table 3: sales \begin{tabular}{|r|r|r|r|} \hline \multicolumn{1}{|c|}{ id } & sales date & book id & sales rrice \\ \hline 1 & $12 / 12 / 2019$ & 1 & 9.99 \\ \hline 2 & $12 / 12 / 2019$ & 2 & 7.99 \\ \hline 3 & $12 / 13 / 2019$ & 1 & 9.99 \\ \hline 4 & $12 / 14 / 2019$ & 1 & 9.99 \\ \hline 5 & $12 / 15 / 2019$ & 4 & 8.99 \\ \hline \end{tabular} 1. a. Find the highest and lowest selling books (that had at least one sale) by quantity during the month of Dec 2019. b. Find the highest and lowest selling books (that had at least one sale) by revenue during the month of Dec 2019. If there are multiple possible books with the same quantity or revenue, sort by author ID and then by publishing year 2. Find the top 3 highest selling authors by quantity from the year with the highest sales revenue, along with these authors' total sales revenue and sales quantity for that year 3. a. Find the oldest published book that the bookstore has. If more than one, share the full list. b. Find the sales price for its most recent sale 4. Find how old would the author be when each book was published 5. If we were to have 1 table on sales that would have all the data from all 3 tables combined,

Public Answer

GXW4RJ The First Answerer