Data retrieval, top,distinct removal of duplicate records

Source: Internet
Author: User

--Data retrieval
--Syntax:
--select Field List/* from table list where condition
----Check all student information
SELECT * FROM Student
--Query with conditions
SELECT * from Student where sex= ' woman '
SELECT * from Student where sex= ' man '
--Query the specified column
Select Studentno,studentname,sex,address,phone from Student
--Set the query result set--the column name of the virtual table
Select Studentno as study number, Studentname name, gender =sex, ' address ' =[address],phone from Student
--select can output a result set or output a constant value
Select 1,2,3,4,5,676,786,8,78
Select
--+ first is an arithmetic operator, and as long as one is a numeric value, the system converts the type on both sides. Can not be converted to an error. If both sides are strings, then + is the string connector
Select 1+ ' 1 '
Select 1+ ' A '
Select ' 1 ' + ' 1 '
--Add constant column Field name = value value need to use ' include
Select Studentno as study number, Studentname name, gender =sex, ' address ' =[address],phone, nationality = ' People's Republic ' from Student

--top, Distinct
--Return to top 5 records
Select Top 5 Studentno as study number, Studentname name, gender =sex, ' address ' =[address],phone, nationality = ' People's Republic ' from Student
--Return percentage
Select top percent Studentno as study number, Studentname name, gender =sex, ' address ' =[address],phone, nationality = ' People's Republic ' from Student

--select CEILING (22*1.0/5)
--distinct Remove duplicate records: Duplicate records are records in which the values of each column are the same. The duplicate records here are for the result set of the query, not for the original physical table
Select Sex,address from Student
Select distinct sex,address from Student

Data retrieval, top,distinct removal of duplicate records

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.