SQL Server Learning

Source: Internet
Author: User
Tags management studio sql server management sql server management studio

Web SQL Server Learning
Database First Impressions: Desktop--web server--database server**
Several large databases: SQL Server, Oracle database, DB2, MYSQL, MongoDB ..... (SQL Structured Query Language)
Install software: SQL Server Management Studio
Attach, detach (Attach, Detach) database files:
Database Diagram diagram:
Relational database:
Two-dimensional table, primary key, foreign key
Introduction to T-SQL:
T-SQL query--queries requests for information from the database;
The most basic SQL query statement--
*select, *from, WHERE, GROUP by, having, ORDER by
Use statement:
  Select...from ... Statement :
  

Select Top  - *  from [Production].[Product] --The Top 100 represents the first 100 rows of data, the * symbol selects all, [Production]. [Product] represents a single tableSelectProductID, Name, ProductNumber, Color, Size, ListPrice fromProduction.Product--elect productid,name,productnumber,color,size,listprice these columnsOrder  byListPricedesc --DESC stands in reverse order,Order  by 2 --2 on behalf of nameIsNull(Name,' ')--IsNull built-in method null value changed to ' '

As keyword Alias
+-*/arithmetic
  WHERE statement:

Select... from...whereSaleperson=275 --use where to implement conditional filtering with and, or, Between...and ...whereName Linke'%moutain%' --using like and% to achieve fuzzy lookupswhereColorinch('Red',' White','Black')whereSize is NULL


  Aggregation functions:

Select Count(SalesPersonID) fromSales.SalesOrderHeaderwhereSalesPersonID isNoNULL    --count number of timesSelect distinct(SalesPersonID) fromSales.SalesOrderHeaderwhereSalesPersonID isNoNULL    --Distinct difference valueSelect AVG(List knowledge) asnaming fromForm--avg represents the average, min represents the minimum, max represents the maximum value, sum represents the sum



  Group BY Usage:

Select sum  as sum of the quantities  from A Group  by Category    -- aggregated into groups according to categories, then the number of individual categories is added



  Having
The purpose of the WHERE clause is to remove rows that do not conform to the where condition before grouping the results of the query, that is, filtering the data before grouping, where the cluster function cannot be included, and the Where condition is used to filter out specific rows.
The HAVING clause is used to filter groups that satisfy a condition, that is, to filter the data after grouping, often with clustering functions, to filter out specific groups using the having condition, or to group by using multiple grouping criteria.

Select sum  as  from A Group  by category  having sum >  -    -- Having the function is to filter after grouping


SQL Server Learning

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.