Page 275 - PYTHON-12
P. 275

This  command,  on  execution,  shall  return  the  minimum  value  from  the  specified  column
                 (Salary) of the table Employee, which is 4500
              •  SUM()

                 SUM() function is used to find the total value of any column or expression based on a column. It
                 accepts the entire range of values as an argument, which is to be summed up on the basis of a
                 particular column, or an expression containing that column name. The SUM() function always
                 takes argument of integer type only. Sums of String and Date type data are not defined.

                 For example,
                     mysql> Select SUM(Salary) from EMPLOYEE;

                 Output:
                 +----------------+
                 | SUM(Salary) |
                 +----------------+

                 | 30700             |
                 +----------------+
                 This command, on execution, shall return the total of the salaries of all the employees from the
                 specified column (Salary) of the table Employee, which is 30700.
              •  AVG()


                 AVG() function is used to find the average value of any column or expression based on a column.
                 Like sum(), it also accepts the entire range of values of a particular column to be taken average
                 of,  or  even  a  valid  expression  based  on  this  column  name.  Like  SUM()  function,  the  AVG()
                 function always takes argument of integer type only. Average of String and Date type data is not
                 defined.

                 For example,
                     mysql> Select AVG(Salary) from EMPLOYEE;

                 Output:
                                                   Ecode       Name         Salary       Job         City
                 +----------------+                  E1   Ritu Jain       NULL       Manager      Delhi
                                                     E2   Vikas Verma     4500       Executive    Jaipur
                 | AVG(Salary)  |
                                                     E3   Rajat Chaudhary  6000      Clerk        Kanpur
                 +----------------+
                                                     E4   Leena Arora     NULL       Manager      Bangalore
                 | 6140               |
                                                     E5   Shikha Sharma   8000       Accountant   Kanpur
                 +----------------+
                 This command, on execution, shall return the average of the salaries of all the employees from
                 the specified column (Salary) of the table Employee, which is 6140.
                                                                                                                  Relational Database and SQL
              •  COUNT()

                 COUNT()  function  is used to count  the number of values in a column. COUNT() takes one
                 argument, which can be any column name, or an expression based on a column, or an asterisk
                 (*). When the argument is a column name or an expression based on the column, COUNT()
                 returns the number of non-NULL values in that column. If the argument is asterisk (*), then
                 COUNT() counts the total number of records/rows satisfying the condition, if any, in the  table.


                                                                                                            12.45
   270   271   272   273   274   275   276   277   278   279   280