標籤:size 資料 lang str des ike col car class
一、實驗素材:
附加學生資訊表(student)
二、實驗要求:
1、 查詢student表中所有學生的資訊
select * from student
2、 查詢student表中“姓名”“所在班級”和“成績”列內容
select 姓名,所在班級,成績 from student
3、 查詢student表中7班的學生姓名
select 姓名 from student where 所在班級=‘7‘
4、 查詢student表中成績為90—100分的學生所有資訊
select * from student where 成績 between 90 and 100
5、 查詢student表中成績低於90分或者高於95分的學生所有資訊
select * from student where 成績<90 or 成績>95
6、 查詢student表中成績為89分,90分的學生所有資訊
select * from student where 成績=89 or 成績=90
7、 查詢student表中姓劉的學生所有資訊
select * from student where 姓名 like ‘劉%’
8、 查詢student表中1班的名叫張紅的學生資訊
select * from student where 所在班級=‘1’ and 姓名=‘張紅’
9、 查詢student表中備忘不為空白的學生所有資訊
select * from student where 備忘 is not null
10、查詢student表中前3行的資料
select top 3 * from student
11、查詢student表中“姓名”和“社會安全號碼”兩列資料,查詢結果“姓名”列名稱顯示為“name”,“社會安全號碼”列名稱顯示為“idcard”
select 姓名 as name,社會安全號碼 as idcard from student
12、查詢student表中所有學生的總成績,列名稱顯示為“總成績”、
select sum(成績) as 總成績 from student
13、 查詢student表中所有學生資訊,並按照成績從高到低顯示查詢結果
select * from student order by 成績 desc
14、 查詢student表中所有學生的平均成績
select avg(成績) as 平均成績 from student
15、 查詢student表中所有學生中的最高分和最低分
select max(成績) as 最高分,min(成績) as 最低分 from student
16、 查詢student表中所有行數
select count(*)總行數 from student
17、 查詢student表中每個班級的總成績
student 所在班級,sum(成績) as 總成績 from student group by 所在班級
18、 查詢student表中總成績大於181分的班級
student 所在班級,sum(成績) as 總成績 from student group by 所在班級 having sum(成績)>181
19、 將student表中1班的學生資訊儲存在表student_1中
student * into aaa from studentwhere 所在班級=‘1
SQL server 資料庫基本插入、刪除命令