Lab 5: SQL Queries The Joins Three-quel

Write some very interesting SQL queries
Work a little harder for the lab points.
Check that your instance of our beloved CAP3 database is exactly the same as mine in the script on our class web site.

Use CAP3 to answer all of these questions.
Show the cities of agents booking an order for a customer whose id is 'c002'. Use
joins; no subqueries.
Show the ids of products ordered through any agent who makes at least one order for a customer in Dallas, sorted by pid from highest to lowest. Use joins; no subqueries.
Show the names of customers who have never placed an order. Use a subquery.
Show the names of customers who have never placed an order. Use an outer join.
Show the names of customers who placed at least one order through an agent in their own city, along with those agent(s') names.
Show the names of customers and agents living in the same city, along with the name of the shared city, regardless of whether or not the customer has ever placed an order
with that agent.
Show the name and city of customers who live in the city that makes the fewest
different kinds of products. (Hint: Use count and group by on the Products table.)
Powered by