data Query-column aliases
Use as to name a column
SELECT SCode as student number, SName as student name, saddress as student address from Students WHERE saddress <> ' Henan Xinxiang '
Use = to name the column
SELECT name = Firstname+ '. ' +lastname from Employees
Attention:
1. + The data type of the connection must be compatible
2. If + Connect character data, the result is a connection to the string data
3. If + connect the numeric data, the result is the value of the
Data query-Limit number of rows
Limit number of fixed lines
SELECT TOP 5 SName, saddressfrom Students WHERE SSex = 0
Returns how many lines
SELECT TOP PERCENT SName, saddressfrom Students WHERE SSex = 0
Query single-column sorting
Ascending order
SELECT StudentID as student number, (SCORE*0.9+5) as comprehensive score from score WHERE (score*0.9+5) >60 ORDER by score
Descending arrangement
SELECT Studentid,score from score ORDER by score DESC
Sort by multiple columns
SELECT StudentID as student number, CourseID as course ID, score as score from score WHERE score > ORDER by CourseID, score
SQL Server database query data