1. -- 操作符
    2. -- distinct 去重
    3. -- 查询grade表里面的具体有哪些科目
    4. select distinct subject from grade;
    5. -- in 多个相同的值
    6. -- 查询学生名称是老子和孔子具体信息
    7. select * from student where name = '孔子' or name = '老子' or name = '朱佳'
    8. select * from student where name in ('孔子','老子','朱佳');
    9. -- not in 不包含这些数据
    10. select * from student where name not in ('孔子','老子','朱佳');
    11. -- GROUP BY 分组
    12. -- 按照科目去分组,然后查询每个组的总分
    13. select subject,sum(score) from grade group by subject;
    14. -- 聚合函数
    15. -- avg(具体的列名)
    16. -- grader表的平均分
    17. select avg(score) from grade;
    18. -- 求语文的平均分
    19. select avg(score) from grade where subject = '语文';
    20. -- count(列名|*)
    21. -- 查询考语文的有几个
    22. select count(*) from grade where subject = '语文';
    23. -- min(列名)
    24. -- 查询语文的最小成绩是多少
    25. select min(score) from grade where subject = '语文';
    26. -- max(列名)
    27. -- 查询语文最高分
    28. select max(score) from grade where subject = '语文';
    29. -- 查询grade表最高分
    30. select max(score) from grade
    31. -- sum(列名)
    32. -- 求数学的总分是多少
    33. select sum(score) from grade where subject = '数学';
    34. -- select 列名 from 表名称
    35. select name from student;
    36. select id,name from student;
    37. -- * 查询所有
    38. select * from student;
    39. -- 使用比较运算符
    40. -- 查询大于60分的数据
    41. select * from grade where score > 60;
    42. -- 查询 成绩不大于60
    43. select * from grade where score !> 60;
    44. select * from grade where score < 60;
    45. -- 查询成绩不等于99的数据
    46. select * from grade where score != 99;
    47. select * from grade where score <> 99;
    48. -- 条件筛选
    49. -- and
    50. --查询成绩大于90 并且 科目是语文
    51. select * from grade where score > 90 and subject = '语文'
    52. -- or
    53. -- 查询姓名是孔子或者老子
    54. select * from student where name = '孔子' or name = '老子';
    55. -- not 姓名不是庄子的
    56. select * from student where name not in ('孔子','庄子')
    57. -- between 范围查询
    58. -- 查询 成绩在90-95之间的
    59. select * from grade where score between 90 and 95;
    60. -- not between 不在这个范围
    61. -- 查询 成绩不在80-90之间的
    62. select * from grade where score not between 80 and 90;
    63. -- 模糊查询
    64. -- %任意字符
    65. -- 查询名字是以子结尾
    66. select * from student where name like '老%';
    67. -- 查询名字中间有马
    68. select * from student where name like '%马%';
    69. -- _ 单个字符
    70. -- 查询名字是x
    71. select * from student where name like '_子';
    72. -- NULL
    73. -- 查询gerade表里面s_idnull
    74. select * from grade where s_id = null; -- 错误写法
    75. -- null值不可以使用等于 is
    76. select * from grade where s_id is null;
    77. -- not null
    78. select * from grade where s_id is not null;
    79. -- top(数量名词) 前几条数据
    80. select top (3) * from student;
    81. -- 排序 order by
    82. -- order by 字段名称 asc | desc
    83. -- asc 升序
    84. select * from grade order by score asc;
    85. -- desc 降序
    86. select * from grade order by score desc;
    87. -- 查询成绩前五名的
    88. select top(5) * from grade order by score desc;