Suspicious e-commerce transactions include orders placed by a customer in one co
ID: 3919924 • Letter: S
Question
Suspicious e-commerce transactions include orders placed by a customer in one country that are shipped to another country. In fact there are no such orders in the Northwind db, so create a few by modifying some of the "Germany" shipcountry entries in the orders table to "Tahiti". Then write a query which finds orders shipped to a different country from the customer.
Hint: in order to do this, you will need to join the Customers and Orders table. Do not hardcode the ShipCountry of 'Tahiti' in the query as this should be for any situation where the shipped to country is different from the country where it was ordered.
Explanation / Answer
Ans) /*This is to modify some of the germany shipcountry entries in customer table*/
UPDATE orders
SET
shipcountry = 'Tahiti'
WHERE
shipcountry='Germany'
/*To find orders shipped to a different country from the customer*/
SELECT*
FROM Customer as C
INNER JOIN
Orders AS O
ON C.CustomerID = O.CustomerID
WHERE C.countryname <> O.shipcountry
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.