Microsoft Sql Server 2017, database Northwind.
Hello everyone, I'm still trying to do these question in sql server, but I stacked and I don't know how to do this. Please give me some tip, how to bite it :P
select *
from
(select companyname, products.productid, productname,[Order Details].OrderID
from [order details], orders, customers, products
where [order details].orderid=orders.orderid AND
orders.customerid=customers.customerid AND
[order details].productid=products.productid) c1
inner join
(select companyname, products.productid, productname, [Order Details].OrderID
from [order details], orders, customers, products
where [order details].orderid=orders.orderid AND
orders.customerid=customers.customerid AND
[order details].productid=products.productid AND
Customers.Country='Brazil') c2
on c1.productId=c2.productId and c1.productname=c2.productname
I'm unsure whether or not customers in Brazil should be excluded from the resulting data, but to point you in the right direction, consider the following query:
Here, the nested selection obtains a distinct set of products purchased by customers in Brazil. The result of this selection is then joined to your
order details
table to obtain all customers who have purchased such products (this will include the Brazilians).