Simple tutorial on SQL statements in linux-simple tutorial on functions and SQL

Source: Internet
Author: User

Simple tutorial on SQL statements in linux-simple tutorial on functions and SQL

Since there are a lot of data in the database that already has numbers, a very important purpose is to be able to perform some operations on these numbers, such as sum them up, or find out their average value. SQL provides some such functions. They are:

  • AVG(Average)
  • COUNT(Count)
  • MAX(Maximum)
  • MIN(Minimum)
  • SUM(Total)

The syntax for using functions is:

SELECT "function name" ("column name ")
FROM "table name ";

For example, if we want to find the sum of the Sales field in our example table,

Store_InformationTable

Store_Name Sales Txn_Date
Los Angeles 1500 05-Jan 1999
San Diego 250 07-Jan-1999
Los Angeles 300 08-Jan 1999
Boston 700 08-Jan 1999

Let's get,

Select sum (Sales) FROM Store_Information;

Result:

SUM (Sales)
2750

2750 represents the sum of all Sales positions: 1500 + 250 + 300 + 700.

In addition to the use of functions, SQL can also perform simple mathematical operations, such as addition (+) and subtraction (-). For text data, SQL also has several functions for text processing, such as text connection (Concatenation), Text trimming (Trim), And sub-string (Substring). Different databases have different syntaxes for these functions, so it is best to refer to the information of your database to determine how these functions are used in that database.


Linux has been tested as follows:



Reprinted, please note: Xiao Liu

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.