Which of the following functions can be used on both numeric as well as non numeric data?

MySQL supports all standard SQL numeric data types. These types include the exact numeric data types (INTEGER, SMALLINT, DECIMAL, and NUMERIC), as well as the approximate numeric data types (FLOAT, REAL, and DOUBLE PRECISION). The keyword INT is a synonym for INTEGER, and the keywords DEC and FIXED are synonyms for DECIMAL. MySQL treats DOUBLE as a synonym for DOUBLE PRECISION (a nonstandard extension). MySQL also treats REAL as a synonym for DOUBLE PRECISION (a nonstandard variation), unless the REAL_AS_FLOAT SQL mode is enabled.

The BIT data type stores bit values and is supported for MyISAM, MEMORY, InnoDB, and NDB tables.

For information about how MySQL handles assignment of out-of-range values to columns and overflow during expression evaluation, see Section 11.1.7, “Out-of-Range and Overflow Handling”.

For information about storage requirements of the numeric data types, see Section 11.7, “Data Type Storage Requirements”.

For descriptions of functions that operate on numeric values, see Section 12.6, “Numeric Functions and Operators”. The data type used for the result of a calculation on numeric operands depends on the types of the operands and the operations performed on them. For more information, see Section 12.6.1, “Arithmetic Operators”.


next → ← prev

SQL Aggregate Functions

  • SQL aggregation function is used to perform the calculations on multiple rows of a single column of a table. It returns a single value.
  • It is also used to summarize the data.

Types of SQL Aggregation Function


Which of the following functions can be used on both numeric as well as non numeric data?

1. COUNT FUNCTION

  • COUNT function is used to Count the number of rows in a database table. It can work on both numeric and non-numeric data types.
  • COUNT function uses the COUNT(*) that returns the count of all the rows in a specified table. COUNT(*) considers duplicate and Null.

Syntax

Sample table:

PRODUCT_MAST

PRODUCTCOMPANYQTYRATECOST
Item1 Com1 2 10 20
Item2 Com2 3 25 75
Item3 Com1 2 30 60
Item4 Com3 5 10 50
Item5 Com2 2 20 40
Item6 Cpm1 3 25 75
Item7 Com1 5 30 150
Item8 Com1 3 10 30
Item9 Com2 2 25 50
Item10 Com3 4 30 120

Example: COUNT()

Output:

10

Example: COUNT with WHERE

Output:

7

Example: COUNT() with DISTINCT

Output:

3

Example: COUNT() with GROUP BY

Output:

Com1    5
Com2    3
Com3    2

Example: COUNT() with HAVING

Output:

Com1    5
Com2    3

2. SUM Function

Sum function is used to calculate the sum of all selected columns. It works on numeric fields only.

Syntax

Example: SUM()

Output:

670

Example: SUM() with WHERE

Output:

320

Example: SUM() with GROUP BY

Output:

Com1    150
Com2    170

Example: SUM() with HAVING

Output:

Com1    335
Com3    170

3. AVG function

The AVG function is used to calculate the average value of the numeric type. AVG function returns the average of all non-Null values.

Syntax

Example:

Output:

67.00

4. MAX Function

MAX function is used to find the maximum value of a certain column. This function determines the largest value of all selected values of a column.

Syntax

Example:

30 

5. MIN Function

MIN function is used to find the minimum value of a certain column. This function determines the smallest value of all selected values of a column.

Syntax

Example:

Output:

10


Next TopicDBMS SQL Join

← prev next →

Which functions can be used on both numeric and non

MAX returns the greatest value in a specified column and can be used with both numeric and non-numeric data.

Which of the following functions can only be used with numeric values?

The AVG function can be only used with numeric values.

Which of the following aggregate functions can not be applied on both number and character typed columns?

You can use the aggregate functions with any type of column, with these exceptions: You can use sum and avg with numeric columns only—bigint, int, smallint, tinyint, unsigned bigint, unsigned int, unsigned smallint, decimal, numeric, float, and money. You cannot use min and max with bit datatypes.

What are the 5 aggregate functions?

There are five aggregate functions, which are: MIN, MAX, COUNT, SUM, and AVG.