O'Reilly logo

Getting Started with MariaDB - Second Edition by Daniel Bartholomew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summarizing data

Sometimes, we are just looking for information about our data. For this, MariaDB has several built-in functions: AVG, COUNT, MIN, MAX, and SUM.

The AVG function

The AVG function is used for obtaining the average of the data in a column. For example, combined with the TIMESTAMPDIFF and CURDATE functions, we can use the AVG function to calculate the average age of all of the people in the employees table.

The CURDATE function doesn't take any arguments and when called, it simply returns the current date.

The TIMESTAMPDIFF function takes three arguments—the unit to count by and two dates, and then outputs the difference between the two. The unit is one of several time units, including MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, and YEAR ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required