Chapter 3. Data retrieval (query)---Select, top, DISTINCT

Source: Internet
Author: User

======select data Query ======

To query all the data in a table:

SELECT * FROM table name

Select Column Name 1, column name 2, column name 3 ... Column name n from table name

To alias a queried column:

Mode 1, original column name as ' Alias '

Mode 2, the original column name ' Alias '

Mode 3, alias = original column name

Get current system time:

Select Current system time =getdate ()

Calculation:

Select

======top data Query ======

Sort:order BY column name Desc (descending)/asc (ascending) default to Ascending

For the first few data, top is typically used with order by:

Select top value the data to be queried from table name order by column to sort Asc/desc

======distinct data Query ======

Data deduplication for the entire result set that has been queried:

SELECT DISTINCT * FROM table name

Chapter 3. Data retrieval (query)---Select, top, 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.