Linux SQL statement concise tutorial --- COUNT, concise tutorial --- count

Source: Internet
Author: User

Linux SQL statement concise tutorial --- COUNT, concise tutorial --- count

As mentioned on the previous page,COUNTIs one of the functions. It is widely used and we will discuss it here. Basically,COUNTThis allows us to count how many pieces of data are selected in the table. Its syntax is:

Select count ("column name ")
FROM "table name ";

For example, if we want to find out which of the following store_name columns in our example table are not blank,

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 count (Store_Name)
FROM Store_Information
WHERE Store_Name is not null;

Result:

COUNT (Store_Name)
4

"Is not null" means "this field is not blank.

COUNTAndDISTINCTIt is often used together to find out how many different pieces of data are in the table (as for what the data is actually not important ). For example, if we want to find out how many different store_names exist in our table, we will enter,

Select count (DISTINCT Store_Name)
FROM Store_Information;

Result:

COUNT (DISTINCT Store_Name)
3


Linux test results:




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.