DATABASE SYSTEMS Lab 4 Solution

$30.00

Category:

Description

In this Lab session you will write 15 SQL queries for the TPCH database. You will execute the queries for the data loaded in Lab 2 and check the results.

Write SQL statements for the following queries on the TPCH database (1 pt. per query):

  1. Print the total amount of money (o totalprice) spent on orders by each customer from FRANCE.

  1. Return the number of suppliers in each country.

  1. How many orders are posted by customers in each country in EUROPE?

  1. How many parts with size below 20 does each supplier from BRAZIL sell?

  1. Find the number of orders posted by each customer from GERMANY in 1995.

  1. How many parts produced by each manufacturer (p mfgr) are ordered at each order priority?

  1. How many orders do customers in each country in ASIA have in each order status?

  1. Print the number of orders completed in 1995 by the suppliers in each country in AMERICA (see or-ders.orderstatus; F stands for complete).

  1. How many di erent clerks did the suppliers in RUSSIA work with?

  1. Find the maximum discount for each type of items having ECONOMY in their type name.

  1. Find the supplier(s) with the largest account balance in every region.

  1. What is the maximum account balance for the suppliers in each region?

  1. How many distinct orders are between suppliers in EUROPE and customers in CANADA?

  1. List the total value (l extendedprice) of all the lineitems sold between any two regions. Print the supplying region, the customer region, and the total value.

  1. How many orders involve a customer with negative balance and a supplier with positive balance?

Instructions. You are required to execute the queries on the TPCH database you populated in Lab 2. We provide you the correct answers for this database. We will check the correctness of your queries on a di erent database. Folder Lab4 under Lab contains an archive lab4-results.zip with the correct answers. There is a le for each query, e.g., 1.out for query 1, 2.out for query 2, etc. You are required to turn in an archive containing a le with the SQL statement for every query. The names of the les have to be 1.sql for query 1, 2.sql for query 2, and so on. There should be exactly 15 les in the archive le. The name of the archive le has to be firstname-lastname-lab4.zip where firstname and lastname are your rst and last names, respectively. The type of the archive le has to be zip.


error: Content is protected !!