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

Source: Internet
Author: User

The SELECT command allows us to read all the data from one or more fields in a table. This will take all the data out, regardless of whether the data values are duplicated or not. In data processing, we often encounter situations where we need to find out the different data values in the table. In other words, we need to know what the different values are in this table/field, and the number of times each value appears is not important. How is this going to be achieved? In SQL, this is easy to do. We just need to add a DISTINCT to the SELECT . The syntax for DISTINCT is as follows:

Select DISTINCT "Field name"
From "table name";

For example, to find out all the different store names in the following table,store_information,

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 DISTINCT store_name from Store_information;

Results:

Store_name
Los Angeles
San Diego
Boston

Test results under Linux:


Reprint please specify: Xiao Liu

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

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.