Mark As Completed Discussion

One Pager Cheat Sheet

  • SQL provides a range of aggregate functions to compute single values from the data collected in a given set of input values, such as AVG(), COUNT(), MIN(), MAX(), and SUM(), while usually ignoring null values.
  • The COUNT() aggregate function returns the number of not null rows in a given column or the entire table and by using the keyword DISTINCT in front of the column name, unique values can be counted.
  • The sum() aggregate function calculates the sum of all values in a numerical column, and its syntax looks like SELECT SUM(column) FROM table WHERE condition;.
  • We cannot use SUM() to calculate the sum of date data type values since it is only applicable to columns containing numerical values.
  • The AVG() function is used to calculate the average of numerical values in a specific column, while ignoring null values.
  • The min() and max() aggregations are used to return the minimum and maximum values of a specific column for several different data types.
  • Using COUNT, MIN, MAX, AVG, and SUM aggregate functions, we can query the Person table to find out the total number of customers, date of the first and last order, average age of the customers, and total number of items ordered.
  • The MIN() aggregate function returns the smallest value in the "City" column of the "Person" table, which is Berlin.