Câu hỏi phỏng vấn MySQL
Câu hỏi

What is an AGGREGATE function. Name few aggregate functions used in MySQL.

Câu trả lời

An aggregate function in MySQL is a function that performs a calculation on multiple values and returns a single value. This type of function is particularly useful for performing operations on a set of values to derive a single summarizing value, such as a sum, average, or count. Aggregate functions are often used in conjunction with the GROUP BY clause to group values into subsets before performing the calculation. They ignore NULL values during the calculation, except for the COUNT function, which counts NULL values when using the COUNT(*) syntax[1][2][3][4][5][6][7][8][9].

Here are a few commonly used aggregate functions in MySQL:

  • COUNT(): Returns the count of a number of rows in a table that match a specified condition. It can count all rows (COUNT(*)), only rows with non-NULL values in a specific column (COUNT(column_name)), or the number of distinct values in a column (COUNT(DISTINCT column_name))[3][4][5][6][7][11].

  • SUM(): Calculates the total sum of a numeric column. It adds up all the values in a specified column and returns the total[3][4][5][6][7][11].

  • AVG(): Returns the average value of a numeric column. It calculates the sum of all non-NULL values in the column and divides it by the number of non-NULL values[3][4][5][6][7][11]...

junior

junior

Gợi ý câu hỏi phỏng vấn

expert

What is difference between horizontal and vertical partitioning? Does MySQL support both horizontal
and vertical partitioning?

expert

Which is better for JOIN & INSERT - PostgreSQL or MySQL?

senior

What is advantage of FULLTEXT over LIKE for performing text search in MySQL?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào