1、返回20%的數據
Select top 20 percent * from students
2、
Sum 總數 :select sum(score) from students 計算學生的總分
Avg 平均值:select avg(score) from students 計算學生的平均分
Max 最大值:select Max(score) from students 計算學生的最高分
Min 最小值:select Min (score) from students 計算學生的最低分
3、查詢奇數列和偶數列彙總
Select sum(表A) from students where ID%2 <> 0
Select sum(表A) from students where ID%2 = 0
4、隨機取出5條數據 newid(),這個函數總是能返回一個新的GUID號碼
Select top 5 * from students order by newid()
5、刪除重複列的數據 distinct
select distinct year(createdate) from students
6、統計一個數據庫中有多少張表
select count(*) from sysobjects where xtype='U'
7、列出數據庫裏所有的表名
select name from sysobjects where type='U'
8、查看硬盤分區
EXEC master..xp_fixeddrives