--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