Question
Question 2: SQL - SELECT queries (20 marks) Provide SQL queries and the result tables for the following (20 marks): Please ensure that you include
Question 2: SQL - SELECT queries (20 marks)
Provide SQL queries and the result tables for the following (20 marks):
Please ensure that you include the result table as well as your SQL; you can copy and paste this from either your ssh client or SQL Developer. Each query is worth 2 marks. These tables exist in arion and are owned by the user dtoohey. You may, if you wish, own copies of the tables under your own account. If you do so, you should ensure that you copy the sample data in dtoohey's tables.
These queries are based on the View Ridge Gallery database you have been using in the Lab sessions. Please see Chapters 6 and 7 of Kroenke for background to the case and table structures.
Link to the book is here https://www.pdfdrive.com/database-processing-e43041985.html
Tables are as followed
ARTIST, CUSTOMER, CUSTOMER_ARTIST_INT
TRANS, WORK
Marks are allocated not only for correct answers, but also for best practice in the creation of the queries.
a. List the details of any works of art (including the Artist who created the work) that have more than three copies recorded in the database.
b. List the details of any work of art (including the Artist who created the work) that has a Surrealist style.
c. List the details of the works of art (including the Artist who created the work, and the acquisition and asking price details) currently held in the gallery (i.e., works of art that have not been sold)
.
d. List the sales for each customer (i.e., when a customer purchases a work of art from the Gallery, a transaction line is created. For a purchase, there will be values in the DateSold and SalesPrice columns). The query should include the details of the customer, the transaction and the work of art purchased.
e. List the names of the deceased artists and the number of years of age they were when they died (for example, an artist born in 1950 and deceased in 2001 has an age of 51).
f. The sum of the acquisition price of works of art for each year (for example, if there were two works of art purchased for $1500 and $1000 in 2019, and one work of art purchased for $500 in 2020, then the sums would be $2500 and $500, for 2019 and 2020 respectively).
g. Calculate the profit made on works of art that have been sold (i.e., the profit/loss on an individual work of art is the difference between the acquisition price and the sales price).
h. Which artist has had the most works of art sold, and how many of the artist's works have been sold?
i. Sales of which artist's works have resulted in the highest average profit (i.e., the average of the profits made on each sale of works by an artist), and what is that amount?
j. Customer name of any customers who have an interest in ALL artists.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started