Chapter 6 Structured Query Language

Chapter 6 Structured Query Language - (SQL Functions...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter 6 Structured Query Language  (SQL) More Complex Queries and SQL  Functions Ordering a Listing ORDER BY <attributes> SELECT P_CODE, P_DESCRIPT, P_INDATE, P_PRICE FROM PRODUCT ORDER BY P_PRICE; SELECT P_CODE, P_DESCRIPT, P_INDATE, P_PRICE FROM PRODUCT WHERE P_INDATE < '08/21/2002' AND P_PRICE <= 50.00 ORDER BY V_CODE, P_PRICE DESC; Listing Unique Values SELECT DISTINCT V_CODE FROM PRODUCT; SELECT V_CODE FROM PRODUCT; More Complex Queries and SQL Functions Function Output COUNT Number of rows containing the specific attribute MIN Minimum attribute value encountered MAX Maximum attribute value encountered AVG Arithmetic mean of attribute values SUM Sum of attribute values COUNT How many products are there?
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
SELECT COUNT(*) FROM PRODUCT ; How many different vendors are represented in the PRODUCT table? SELECT COUNT(DISTINCT V_CODE) FROM PRODUCT WHERE V_CODE IS NOT NULL ; SUM Calculate inventory value SELECT SUM(P_ONHAND*P_PRICE) FROM PRODUCT; Average AVG What is the average product price
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern