Category: Functions
-
last function
MySQL last function is used to return the last value of the selected column. Syntax: MySQL last function example Consider a table “officers” having the following data. Execute the following query: This query will return the last officer_name ordering by officer_id. Output: Return the last officer_name ordering by officer_name: Output:
-
first function
The MySQL first function is used to return the first value of the selected column. Here, we use limit clause to select first record or more. Syntax: MySQL first function example To SELECT FIRST element: Consider a table named “officers”, having the following data. Execute the following query: Output: To SELECT FIRST two records Output:
-
GROUP_CONCAT() Function
The GROUP_CONCAT() function in MySQL is a type of an aggregate function. This function is used to concatenate string from multiple rows into a single string using various clauses. If the group contains at least one non-null value, it always returns a string value. Otherwise, you will get a null value. The following are the…
-
MAX() Function
The MySQL MAX() function is used to return the maximum value in a set of values of an expression. This aggregate function is useful when we need to find the maximum number, selecting the most expensive product, or getting the largest payment to the customer from your table. Syntax The following is the basic syntax…
-
MIN() Function
The MIN() function in MySQL is used to return the minimum value in a set of values from the table. It is an aggregate function that is useful when we need to find the smallest number, selecting the least expensive product, etc. Syntax The following is the basic syntax of MIN() function in MySQL: Parameter explanation This function…
-
avg() function
The MySQL avg() is an aggregate function used to return the average value of an expression in various records. Syntax The following are the basic syntax an avg() function in MySQL: Parameter explanation aggregate_expression: It specifies the column or expression that we are going to find the average result. table_name: It specifies the tables from where we…
-
sum() function
The MySQL sum() function is used to return the total summed value of an expression. It returns NULL if the result set does not have any rows. It is one of the kinds of aggregate functions in MySQL. Syntax Following are the syntax of sum() function in MySQL: Parameter Explanation aggregate_expression: It specifies the column or expression that…
-
Count() Function
MySQL count() function is used to returns the count of an expression. It allows us to count all rows or only some rows of the table that matches a specified condition. It is a type of aggregate function whose return type is BIGINT. This function returns 0 if it does not find any matching rows.…
-
Aggregate Functions
MySQL’s aggregate function is used to perform calculations on multiple values and return the result in a single value like the average of all values, the sum of all values, and maximum & minimum value among certain groups of values. We mostly use the aggregate functions with SELECT statements in the data query languages. Syntax: The following are the…