Chapter 6 Assignment Exercises

# Chapter 6 Assignment Exercises - CLINTRICIA BAKER ITSE 2409...

• Homework Help
• 2

This preview shows page 1 - 2 out of 2 pages.

/* CLINTRICIA BAKER - ITSE 2409 DATABASE PROGRAMMING */ /* CHAPTER 6 HOW TO CODE SUBQUERIES */ /*ex6-1*/ SELECT DISTINCT CategoryName FROM Categories WHERE CategoryID IN (SELECT CategoryID FROM Products) ORDER BY CategoryName /* ex6-2 pg 196 */ SELECT ProductName, ListPrice FROM Products WHERE ListPrice > (SELECT AVG (ListPrice) FROM Products) ORDER BY ListPrice DESC /* ex6-3 pg 198 */ SELECT DISTINCT CategoryName FROM Categories WHERE NOT EXISTS (SELECT CategoryID FROM Products WHERE Categories.CategoryID = CategoryID) ORDER BY CategoryName /* ex6-4 pg */ /* I could not figure this one out SELECT EmailAddress, OrderID, COUNT (*) AS OrderTotal FROM Customers, OrderItems GROUP BY EmailAddress, OrderID

#### You've reached the end of your free preview.

Unformatted text preview: SELECT EmailAddress, MAX(OrderID) FROM (SELECT EmailAddress, OrderID, Count (*) AS OrderTotal FROM Customers, OrderItems GROUP BY EmailAddress, OrderID) */ /* ex6-5 */ SELECT p1.ProductName, p1.DiscountPercent FROM Products AS p1 WHERE p1.DiscountPercent NOT IN (SELECT p2.DiscountPercent FROM Products AS p2 WHERE p1.ProductName &lt;&gt; p2.ProductName) ORDER BY ProductName /* ex6-6 */ /* I could not figure this one out SELECT c.EmailAddress AS EmailAddress, o.OrderId AS OrderId, o.OrderDate AS OrderDate FROM Customers c JOIN Orders o ON c.CustomerID = CustomerID AND o.OrderDate = (SELECT MIN(OrderDate) FROM Orders WHERE CustomerID = c.CustomerID) */...
View Full Document

• Fall '14

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern