Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Database Schema: Customer(c_custkey, c_name, c_address, c_nationkey, c_phone, c_

ID: 3581386 • Letter: D

Question

Database Schema:

Customer(c_custkey, c_name, c_address, c_nationkey, c_phone, c_acctbal, c_mktsegment, c_comment)
Suppliers(s_suppkey, s_name, s_address, s_nationkey, s_phone, s_accbal, s_comment)
Nation(n_nationkey, n_name, n_regionkey, n_comment)
Region(r_regionkey, r_name, r_comment)
Orders(o_orderkey, o_custkey, o_orderstatus, o_totalprice, o_orderdate)
Lineitem(l_orderkey, l_suppkey, l_linenumber, l_quantity)

What I have so far:

select distinct count(*) from

(

(SELECT *
FROM supplier, nation, lineitem, orders
WHERE s_nationkey = n_nationkey
AND n_name = 'EUROPE'
AND l_suppkey = s_suppkey
AND l_orderkey = o_orderkey) AS supplier

JOIN

(SELECT *
FROM nation, customer, orders
WHERE n_nationkey = c_nationkey
AND o_custkey = c_custkey
AND n_name = 'Brazil') AS customer

ON supplier.o_orderkey = customer.o_orderkey);

PLEASE HELP! Thank You!

13. How many transactions are between su in EUROPE and custom in BRAZIL

Explanation / Answer

select count(*) from Orders where o_custkey in (select c_custkey from Customer where c_nationkey in(select n_nationkey from Nation where n_name='Brazil')) AND o_orderkey in(select l_orderkey from Lineitem where l_suppkey in (select s_suppkey from Supplier where s_nationkey in(select n_nationkey from Nation where n_name='Europe')))