Query statement:
SQL Sever query statement;
1. Query all fields:
SELECT * FROM UserInfo
2. Conditional screening
(such as querying the username in userinfo)
Select UserName from UserInfo
WHERE statement:
SELECT * from UserInfo where sex= ' man ' and major= ' computer ' (and/or)
Top statement: Top 5* ... order by ... desc (desc marked descending-not written is ascending ) Note (number plus *) Brder by
Select Top UserInfo from the Where major= ' computer ' ORDER BY age DESC
Max: Query for the maximum number of values ( such as the oldest in the age field of the query )
Select Max(age) from UserInfo
Minimum-----min avg Avg
Sum: Sum (as follows, query age sum)
Select SUM(age) from UserInfo
count: Quantity ( such as the number of students who have computer majors found in all data )
Select Count(*) from UserInfo where major= ' computer '
As : Give the queried field an individual name, convenient for later use ( such as the above query results named UserCount)
Select COUNT (*) as UserCount from UserInfo where major= ' computer '
GROUP BY: Query result grouping () having Count (*) >3 (where cannot be used at this time)
Select COUNT (*) as Groupcount,major from UserInfo group by Major have count (*) >3
Like: Fuzzy query
SELECT * from UserInfo where reaname like '% sheet% '
Sqlsever Query Basic