# SPL general table operations

## 1.Filter

Filter out the records that meet the conditions from the data table.

Example: Filter the student scores of class 10 from the student score table Students_scores.txt. The first row of the file is the column name, and the second row is the data, as shown in the figure below.

A1 reads the data in the file and then selects the data record of class 10. The T function will automatically select the appropriate separator based on the file extension.

## 2.Summary

Summarize the data in the data table.

Example: Calculate the average Chinese score, the highest score in mathematics, and the total score in English for all students.

A1 reads the data in the file, and the T function automatically selects a suitable separator according to the file extension.

A2 Calculate the average language score.

A3 Calculate the highest score in mathematics.

A4 calculate English total score.

## 3.Cross-column calculation

Perform cross-column calculations in the data table.

Example: Calculate the total score of each student.

A1 reads the data in the file, and the T function automatically selects a suitable separator according to the file extension.

A2 adds a column total_score to A1, whose value is the sum of the three columns of English, Chinese, and Mathematics

The results in A2 are as follows:

## 4.Sort

Sort the data in ascending/descending order.

Example: Arrange the student transcript in ascending order of class number and descending order of total score.

A1 reads the data in the file, and the T function automatically selects a suitable separator according to the file extension.

A2 sorted by class number in ascending order.

A3 is first arranged in ascending order of class number and then in descending order of mathematics results.

## 5.Group summary

Group and summarize the data in the data table.

Example: Query the lowest score in English, highest score in Chinese, and total score in mathematics for each class.

A1 reads the data in the file, and the T function automatically selects a suitable separator according to the file extension.

A2 A1 is grouped by class to calculate the lowest score in English, the highest score in Chinese, and the total score in mathematics for each class.

## 6.Filter after grouping

Group and summarize the data in the data table before filtering.

Example: Find classes with an average score of less than 70 in English.

A1 reads the data in the file, and the T function automatically selects a suitable separator according to the file extension.

A2 Group A1 by class, calculate the average English score of each class and name the new column named avg_En.

A3 selects from A2 those with an average English score of less than 70

The query results in A3 are as follows:

## 7.Association

### 7.1 Associative calculation

Perform correlation calculations on the data in the two data tables.

Example: The sales order information and product information are stored in two Excel files, respectively, and the sales amount of each order is calculated. The data structure of the two files is as follows:

A2 Read product information data, set ID as the primary key

A3 associates A1 with the primary key in A2 according to ProductID , and at the same time takes out Name and Price column data.

A4 A3 adds a new column of amount, and its value is the sales quantity Quantity multiplied by the product price Price.

### 7.2 Associative query

Perform an associated query on the data in the two data tables.

Example: Still use the two files in the previous section to query sales orders with product prices greater than 20 yuan.

A2 Read the product information data, select the product information with a price greater than 20, and then set the ID as the main key.

A3  according to ProductID, A1 to be associated with the primary key of A2, the option @i represents A2 is not found in the ProductID match the product ID, then this record was filtered off.

### 7.3 query main table and subtable

Associative query on the main table and detailed table data, Example: Some data in the employee information table employee.xlsx and employee family member table family.xlsx are as follows. Please query the information of employees who have an elderly person over 70 years old at home.