SQL server 資料庫基本插入、刪除命令

來源:互聯網
上載者:User

標籤: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 資料庫基本插入、刪除命令

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.