SQL Server Foundation

Source: Internet
Author: User

1.select query columns, restrictions on columns, where filter rows, restrictions on rows; Group by set operations, such as averaging; having a limit on the value of a set operation, such as a mean greater than 30;order by to the collation limit (default increment)

2.f5 execution, effect equivalent to execute

3.select top from table; detect the first 100 rows of data

4. Order by; Select Id,name,price from Product order by name Desc,price; Sort by name in descending order, and then increment by price in the same name

Select Id,name,price from Product order by 2; Ascending sort by the second column (that is, the name column)

5. IsNull function: Determine whether a certain data is empty;

Select ID, Name, isnull (Price, ") from Product order by name Desc,price; In order not to bother the user, if Price is null, the result of the query will be empty

6. As Keyword: alias table columns:

Select ID, Name, isnull (Price, ") as price123 from Product order by name Desc,price; After IsNull (price, ") operation, the original price column is not listed, this time give the column name price123

7. + Keyword: Connect "columns" to "strings":

Select ID, name, price, name + ' product prices are ' + CONVERT (varchar,price) from product order by name Desc,price; CONVERT (varchar,price) data type conversion, the price of money type to varchar type to facilitate string concatenation

8. Arithmetic expression: +-*/

Select ID, name, rate as ' hourly wage ', round (rate*40*52,1) as ' annual salary ', round (rate*40*52,0) as ' annual salary ' from Employee; Round (rate*40*52,1) after the decimal point is rounded to retain 1 bits, round (rate*40*52,0) rounding not decimal places

Select ID, name, rate as ' hourly wage ', (rate+5) *40*52 as ' annual salary ' from Employee; (rate+5) *40*52 Change the priority of operations

  

    

      

SQL Server Foundation

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.