A concise tutorial of SQL statements for Linux---COUNT

Source: Internet
Author: User

As mentioned on the previous page,COUNT is one of the functions. Because of its wide use, we have made a special offer here to discuss it. Basically,Count allows us to count how many of the data in the table is selected. Its syntax is:

Select COUNT ("Field name")
From "table name";

For example, if we want to find out how many of the Store_name columns in our demo table are not blank data,

store_information Form

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

We'll break in,

SELECT COUNT (store_name)
From Store_information
WHERE Store_name is not NULL;

Results:

COUNT (Store_name)
4

"is not NULL" means "this field is not blank".

COUNT and DISTINCT are often used together in order to find out how many different data are in the table (as to what is actually unimportant). For example, if we were to find out how many different store_name we had in our table, we would break in,

SELECT COUNT (DISTINCT store_name)
from Store_information;

Results:

COUNT (DISTINCT store_name)
3


Linux measured results:




Reprint please specify: Xiao Liu

A concise tutorial of SQL statements for Linux---COUNT

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.