This is the 14th day of my participation in Gwen Challenge
Author: Cola
Source: Coke’s path to data analysis
Please contact authorization for reprinting (wechat ID: data_COLA)
Arithmetic operators calculate fields
Select column arithmetic operator from table;
A new field can be created using the addition, subtraction, multiplication and division operators, or functions that create fields directly after the select command.
To name a newly created field, use the [AS] command
Add +5 to each score column in the SC table to create a new score2 field as follows:
Second, function calculation field
01 Date Function
YEAR(), MONTH() and DAY() are used in the date function to extract all data under a certain date. In the following example, to extract students born on March 3, 2003, you can omit the DATE() function because the sage column is already in the DATE format. Note that the DATE is filtered with single quotes.
In the following example, extract the records of all students born in 2003.
02 Text Function
A function that operates on character data,
【left】 Extract the last name of each student
03 Numerical Functions
A function that processes numeric data. Common ones are:
The result column is rounded
Aggregation function
Functions that summarize numerical data include the following:
The aggregate function yields a single piece of data rather than a series of queries.
01 count function
The Count function counts rows.
–select count(*) from table –select count(DISTINCT columns) from table –select count(DISTINCT columns) from table –select count(DISTINCT columns) from table
Student1 table student1: select * from student1
02 sum function
The Sum function is the Sum over a specified column.
–select sum from table
Sum the results column in the SC table.
Sum over the grades of student number 1:
03 avg function
The Acg function is used to average the columns
Select avg from table
Average the grade column
04 Max function
Returns the maximum value in the specified column.
Select Max from table
Find the highest grade
5 min function
Returns the minimum value in the formulated column.
–select min from table
Find the lowest grade
Comprehensive application of aggregation function
Descriptive statistical analysis