1. General Enquiry:
SELECT * FROM Info #查询Info all the contents of the table
Select Name,code from Info #查询Info table Name,code Column
2. Conditional query
SELECT * from Info where sex=1# query for cells with Sex 1 in the info table
SELECT * from Info where sex=1 and nation= ' n001 ' #查询Info表中Sex = 1 and nation=n001 data
SELECT * from Info where sex=1 or nation= ' n001 ' #查询Info表中Sex =1 or nation=n001 data
3. Fuzzy query
SELECT * from chinastates where areaname like ' in% ' #查询Chinastates表 data starting in the AreaName column
SELECT * from chinastates where areaname like '% in% ' #查询ChinaStates表中AreaName列中包含中的数据
SELECT * from chinastates where areaname like ' _ in% ' #查询ChinaStates表中AreaName列中第二个字为中的数据
4. Sort queries
SELECT * from Car ORDER BY Code Desc #查询Car表中按Code列降序排列
SELECT * from Car ORDER by Code ASC #查询Car表中按Code列升序排列
SELECT * FROM Car order by Code, brand# query Car table in Code,brand arrangement
5. Statistical queries (aggregation functions)
Select COUNT (oil) from Car #查询Car the number of rows in the oil column in the table
Select Max from Car #查询Car表中Oil列中最大的数据
Select min (oil) from Car #查询Car表中Oil列中最小的数据
Select Avg. from Car #查询Car表中Oil列数据的平均值
6. Group queries
Select Code,brand, COUNT (*) from car GROUP by brand# query the car table for groups to view the number of data bars per group
SELECT * FROM Car GROUP by Brand have Count (*) >1 #查询Car表中分组查看Brand中数据条数大于2的
7. Paging Query
SELECT * from Car limit 5,5 #查询Car表中跳过5条数据取5条数据
(3.13) T-SQL simple query