CC SQL 12. summarizing Data

Card Set Information

Author:
dau108
ID:
146334
Filename:
CC SQL 12. summarizing Data
Updated:
2012-04-08 05:07:29
Tags:
CC SQL 12 summarizing Data
Folders:

Description:
CC SQL 12. summarizing Data
Show Answers:

Home > Flashcards > Print Preview

The flashcards below were created by user dau108 on FreezingBlue Flashcards. What would you like to do?


  1. using aggregate functions
    • Function Description
    • AVG() Returns a column's average value
    • COUNT() Returns the number of rows in a column
    • MAX() Returns a column's highest value
    • MIN() Returns a column's lowest value
    • SUM() Returns the sum of a column's values
  2. aggregates on distinct values
    • The five aggregate functions can all be used in two ways:
    • 1. To perform calculations on all rows, specify the ALL argument, or specify no argument at all (because ALL is the default behavior).
    • 2. To only include unique values, specify the DISTINCT argument.

    Tip ALL Is Default The ALL argument need not be specified because it is the default behavior. If DISTINCT is not specified, ALL is assumed.

    • example:
    • SELECT AVG(DISTINCT prod_price) AS avg_price
    • FROM products
    • WHERE vend_id = 1003;
  3. combining aggregate functions
    • SELECT COUNT(*) AS num_items,
    • MIN(prod_price) AS price_min,
    • MAX(prod_price) AS price_max,
    • AVG(prod_price) AS price_avg
    • FROM products;

What would you like to do?

Home > Flashcards > Print Preview