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