SQL Server database query data

Source: Internet
Author: User

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

Related Article

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.