zoukankan      html  css  js  c++  java
  • SQL server 数据库基本插入、删除命令

    一、实验素材:

    附加学生信息表(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

  • 相关阅读:
    xen虚拟机管理命令
    ipmi
    http://classworlds.codehaus.org/apiusage.html
    maven编译问题之 -The POM for XXX is invalid, transitive dependencies (if any) will not be available
    SSM项目web.xml等配置文件中如何查找类的全路径名?
    shiro安全框架学习-1
    ht-8 对arrayList中的自定义对象排序( Collections.sort(List<T> list, Comparator<? super T> c))
    ht-7 treeSet特性
    ht-6 hashSet特性
    ht-5 treemap特性
  • 原文地址:https://www.cnblogs.com/L2366/p/9128062.html
Copyright © 2011-2022 走看看